Reputation: 63
I am aware that this has been asked (and answered) often, but the solutions are not working for me. I get this error from last days, and I tried everything :
I changed the port and the host and the SMTPSecure to (ssl / 465).
The port is open (587 and 465).
My php installation has SSL support.
The php function mail() worked perfectly
I have the last version of phpmailer
When i put the smtpAuth , i have an other line error (ERROR: AUTH not accepted from server: 530 5.7.0 Must issue a STARTTLS command first.)
I put my php.ini configuration : SMTP = smtp.gmail.com smtp_port = 587
I also tried (it seems more logical) : SMTP = smtp.myFAI.com smtp_port = 25
I think it's more a php issue than the code. Thank you for reading my annoying post ! And if you have any ideas...
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Password='password';
$mail->SetFrom("my_email", 'Me');
$mail->AddAddress("email_to", "");
$mail->From = "my_email";
$mail->FromName= "Me";
$mail->IsHTML(false);
$mail->Subject="Subject";
$mail->Body = "message";
if(!$mail->Send()){echo "not sent";}
else{echo "Sent";}
Upvotes: 3
Views: 13903
Reputation: 63
I have a solution for my problem . I don't know why it's working, I just add 'ssl://' to the host :
$mail->SMTPSecure = 'ssl';
$mail->Host = 'ssl://smtp.gmail.com';
$mail->Port = 465;
I had already check this combination (ssl/465), so the solution was adding 'ssl://' to the host.
Upvotes: 2