Answer the question
In order to leave comments, you need to log in
How to work with PHPmailer?
I can't figure out how to send mail using PHP. Initially, I used the mail () function, but letters came only to yandex, to mail.ru (bk.ru), gmail.com - they do not come. I started searching the Internet for a solution to the problem and, in the end, I decided that it was worth trying PHPmailer. No indication Host
SMTPAuth
Port
SMTPSecure
Username
Password
. If I understand correctly, then these parameters must be specified if you want to use not the default server for sending letters, but, for example, the yandex server. And, if you have a yandex account, then I must enter the data corresponding to my account in the fields described above. So I tried, but now the letter does not come anywhere at all! What did I misunderstand? Here is the code:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.yandex.ru';
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->Port = '465';
$mail->SMTPSecure = 'ssl';
$mail->CharSet = 'UTF-8';
$mail->Username = '[email protected]';
$mail->Password = '123';
$mail->Subject = $subject;
$mail->Body = $html_body;
$mail->setFrom('[email protected]', 'mysite');
$mail->AddAddress($to_address);
$mail->Send();
Answer the question
In order to leave comments, you need to log in
If you think that emails to gmail did not come due to incorrect settings - this is not entirely true.
Once upon a time, when the trees were big and the internet was small, emails could be sent by anyone to anyone. And now many mail servers want all sorts of digital signatures and certificates from the sender - they are fighting spam like that.
So you need either a correctly configured smtp server with all signatures and seals on the tail, or contact the administrator of this "default server" with the question "why do I not receive letters to gmail.com".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question