×


PHPMailer SMTP error password command failed - Fix it Now ?

Sometimes we can encounter this SMTP error when we try to send mail using phpmailer():

SMTP ERROR: Password command failed: 534-5.7.14

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related SMTP queries.

In this context, we shall look into methods to resolve this error.


Nature of PHPMailer SMTP error password command failed

Basically, this error happens as a result of the following reasons:

1. When a less secure application tries to use the email account.

2. If we try to log in several times a row

3. If we change countries (For example, use VPN, move code to a different server, or actually try to login from a different part of the world).


Now, lets see how to resolve this error.


Solution 1: In the case of the Windows server

a. PHP.ini

i. Initially, we go to C:\xampp\php, edit the php.ini file with notepad.

ii. Under the [mail munction] section, we remove the semicolon for this line:

sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”

iii. Then we add a semicolon for this line:

sendmail_path=”C:\xampp\mailtodisk\mailtodisk.exe”


b. SendMail.ini

i. Here, we go to C:\xampp\sendmail, edit the sendmail.ini file with notepad

ii. Then we change the following:

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=your-gmail-username@gmail.com
auth_password=your-gmail-password
force_sender=your-gmail-username@gmail.com

smtp_port should tally with what is written in our php code.


Solution 2: Enable less secure applications (SMTP server is Gmail)

i. Initially, we login to the account via web

ii. Then we view recent attempts to use the account and accept suspicious access:

https://security.google.com/settings/security/activity?hl=en&pli=1

iii. We can disable the feature of blocking suspicious apps/technologies:

https://www.google.com/settings/u/1/security/lesssecureapps


Solution 3: (SMTP server is Gmail)

i. Initially, login to the account via web

ii. Access the URL: https://accounts.google.com/b/0/DisplayUnlockCaptcha

iii. Then we click the continue option

iv. We can check whether phpmailer is set as SMTP with SSL.


This will work if our SMTP server is Gmail.


Solution 4: Change SMTPSecure value from SSL to TLS in phpmailer() code.


Solution 5: In the case of Gsuite

In such a case, we have to solve it as the Administrator.

i. Go to Admin panel >> Security with Shield icon >> Basic settings

ii. Then go to the Less secure apps section

iii. Now we select one of the Radio Button:

a) Disable access to less secure apps for all users (Recommended).

b) Allow users to manage their access to less secure apps.

c) Enforce access to less secure apps for all users (Not Recommended).


Generally, if option a) does not work, it will start to work with the c) option.


Solution 6: In the case of cPanel/WHM servers

This is related to a security feature in WHM/cPanel.

i. Firstly, log in to CPanel.

ii. Navigate to Tweak Settings > All > "Restrict outgoing SMTP to root, Exim, and mailman".

iii. Eventually, switch it from "On" to "Off".


In addition, we can do this via SSH as well:

/scripts/smtpmailgidonly off


[Need help with the solution to this SMTP error? We'd be happy to assist. ]


Conclusion

This article covers methods to resolve PHPMailer SMTP error password command failed. 


To fix this SMTP issue, you need to:

1) Login to your Gmail account using the web browser.

2) Click on this link to enable applications to access your account: https://accounts.google.com/b/0/DisplayUnlockCaptcha

3) Click on Continue button to complete the step.

4) Now try again to send the email from your PHP script. It should work.