Sometimes we can encounter this SMTP error when we try to send mail using phpmailer():
SMTP ERROR: Password command failed: 534-5.7.14
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
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:
i. Here, we go to C:\xampp\sendmail, edit the sendmail.ini file with notepad
ii. Then we change the following:
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:
iii. We can disable the feature of blocking suspicious apps/technologies:
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: