cicette
cicette

Reputation: 63

PHPMailer : MAIL not accepted from server: 530 5.7.0 Must issue a STARTTLS command first

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 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

Answers (1)

cicette
cicette

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

Related Questions