Unable to send email using Gmail SMTP server through PHPMailer, getting error: SMTP AUTH is required for message submission on port 587. How to fix?

It can be difficult to send email through Gmail's SMTP server. In this article, we'll cover some of the steps to take to fix this issue. First, we need to make sure we're using the correct SMTP settings. Log into your Gmail account and go to Settings > Forwarding and POP/IMAP > Add a forwarding address. Next, click on Add a forwarding address. In the popup window, enter your email address and then click Add. Next, go to Settings > Accounts and Import > Add another email account you own. Enter your email address and password, then click Next Step. Choose SMTP as the Account Type and enter smtp.gmail.com as the Outgoing mail server (or IP address). Then, enter 587 as the Outgoing port and click Next Step. Lastly, click on Advanced Settings and make sure SSL is enabled. Now you should be able to send email through Gmail's SMTP server.

Unable to send email using Gmail SMTP server through PHPMailer, getting error: SMTP AUTH is required for message submission on port 587. How to fix?

1.In your Google/Gmail account, go to Settings.

2.Select the 'Forwarding and POP/IMAP' settings.

3.Under the 'IMAP access' section, toggle on the option to 'Enable IMAP. ...

4.In your Accredible instance, click on 'Emails' at the top of your Accredible dashboard.

5.In the left-hand sidebar menu, click on 'SMTP Overrides



$mail
= new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail $mail->Host = "smtp.gmail.com"; $mail->Port = 465; // or 587 $mail->IsHTML(true); $mail->Username = "email@gmail.com"; $mail->Password = "password"; $mail->SetFrom("example@gmail.com"); $mail->Subject = "Test"; $mail->Body = "hello"; $mail->AddAddress("email@gmail.com"); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; }

This code above has been tested and worked for me.

It could be that you needed $mail->SMTPSecure = 'ssl';

Also make sure you don't have two step verification switched on for that account as that can cause problems also.

UPDATED

You could try changing $mail->SMTP to:

$mail->SMTPSecure = 'tls';

It's worth noting that some SMTP servers block connections. Some SMTP servers don't support SSL (or TLS) connections.