{"id":302,"date":"2022-02-22T01:13:45","date_gmt":"2022-02-22T01:13:45","guid":{"rendered":"http:\/\/basicwebsitesolutions.com\/blog\/?p=302"},"modified":"2022-02-22T01:13:47","modified_gmt":"2022-02-22T01:13:47","slug":"phpmailer-smtp-error-password-command-failed","status":"publish","type":"post","link":"https:\/\/basicwebsitesolutions.com\/blog\/2022\/02\/22\/phpmailer-smtp-error-password-command-failed\/","title":{"rendered":"PHPMailer \u2013 SMTP error password command failed"},"content":{"rendered":"\n<p>Hey guys, i have been experimenting with smtp and gmail for sending to clients using php. Found this wonderful article and thought of saving it here on my blog as a keepsafe. Unfortunately, bobcares does like his blogs to be posted anywhere else. Such a shame.<\/p>\n\n\n\n<p>Anyways, hope you enjoyed the research. It helped me through mine. <\/p>\n\n\n\n<p>Leave some comments blow.<\/p>\n\n\n\n<p>Coffee Cup<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p id=\"phpmailer_smtp_failed\"><\/p>\n\n\n\n<p>phpmailer-smtp-error-password-command-failed<\/p>\n\n\n\n<p><em>Stuck with PHPMailer \u2013 SMTP error password command failed? We can help you.<\/em><\/p>\n\n\n\n<p>We may come across this error when we try to send mail using phpmailer().<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SMTP ERROR: Password command failed: 534-5.7.14<\/pre>\n\n\n\n<p>As part of our&nbsp;<a href=\"https:\/\/bobcares.com\/server-management\/\">Server Management Services<\/a>, we assist our customers with several SMTP queries.<\/p>\n\n\n\n<p>Today, let us see how to fix this error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PHPMailer \u2013 SMTP error password command failed<\/h2>\n\n\n\n<p>This error may occur due to the below reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>When a less secure application tries to use the email account.<\/li><li>If we try to log in several times a row<\/li><li>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).<\/li><\/ul>\n\n\n\n<p>Moving ahead, let us see the methods our&nbsp;<a href=\"https:\/\/bobcares.com\/server-management\/\">Support Techs<\/a>&nbsp;employ in order to fix this.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Solution 1: In the case of the Windows server<\/h4>\n\n\n\n<p>PHP.ini<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Initially, we go to&nbsp;<strong>C:\\xampp\\php<\/strong>, edit the&nbsp;<strong>php.ini<\/strong>&nbsp;file with notepad.<\/li><li>Under the [mail munction] section, we remove the semicolon for this line:sendmail_path = \u201c\\\u201dC:\\xampp\\sendmail\\sendmail.exe\\\u201d -t\u201d<\/li><li>Then we add a semicolon for this line:sendmail_path=\u201dC:\\xampp\\mailtodisk\\mailtodisk.exe\u201d<\/li><\/ol>\n\n\n\n<p>SendMail.ini<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Here, we go to&nbsp;<strong>C:\\xampp\\sendmail<\/strong>, edit the&nbsp;<strong>sendmail.ini<\/strong>&nbsp;file with notepad<\/li><li>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<\/li><\/ol>\n\n\n\n<p>smtp_port should tally with what is written in our php code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Solution 2: Enable less secure applications (SMTP server is Gmail)<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>Initially, we login to the account via web<\/li><li>Then we&nbsp;<strong>view<\/strong>&nbsp;recent attempts to use the account and accept suspicious access:<br><a href=\"https:\/\/security.google.com\/settings\/security\/activity?hl=en&amp;pli=1\">https:\/\/security.google.com\/settings\/security\/activity?hl=en&amp;pli=1<\/a><\/li><li>We can&nbsp;<strong>disable<\/strong>&nbsp;the feature of blocking suspicious apps\/technologies:<br><a href=\"https:\/\/www.google.com\/settings\/u\/1\/security\/lesssecureapps\">https:\/\/www.google.com\/settings\/u\/1\/security\/lesssecureapps<\/a><\/li><\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Solution 3: (SMTP server is Gmail)<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>Initially, login to the account via web<\/li><li>Access the URL:&nbsp;<a href=\"https:\/\/accounts.google.com\/b\/0\/DisplayUnlockCaptcha\">https:\/\/accounts.google.com\/b\/0\/DisplayUnlockCaptcha<\/a><\/li><li>Then we click the&nbsp;<strong>continue&nbsp;<\/strong>option<\/li><li>We can check whether phpmailer is set as SMTP with SSL.<\/li><\/ol>\n\n\n\n<p>This will work if our SMTP server is Gmail.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Solution 4: Change SMTPSecure value from SSL to TLS in phpmailer() code.<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">Solution 5: In the case of Gsuite<\/h4>\n\n\n\n<p>In such a case, we have to solve it as the Administrator.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Go to&nbsp;<strong>Admin<\/strong>&nbsp;panel &gt;&gt;&nbsp;<strong>Security<\/strong>&nbsp;with Shield icon &gt;&gt;&nbsp;<strong>Basic settings<\/strong><\/li><li>Then go to the<strong>&nbsp;Less secure apps<\/strong>&nbsp;section<\/li><li>Now we select one of the Radio Button:<\/li><\/ol>\n\n\n\n<p>a) Disable access to less secure apps for all users (Recommended)<br>b) Allow users to manage their access to less secure apps<br>c) Enforce access to less secure apps for all users (Not Recommended)<\/p>\n\n\n\n<p>Generally, if option a) does not work, it will start to work with the c) option.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Solution 6: In the case of cPanel\/WHM servers<\/h4>\n\n\n\n<p>This is related to a security feature in WHM\/cPanel.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Firstly, log in to&nbsp;<strong>CPanel<\/strong><\/li><li>Navigate to<strong>&nbsp;Tweak Settings<\/strong>&nbsp;&gt;&nbsp;<strong>All<\/strong>&nbsp;&gt; \u201c<strong>Restrict outgoing SMTP to root, Exim, and mailman<\/strong>\u201d<\/li><li>Eventually, switch it from \u201c<strong>On<\/strong>\u201d to \u201c<strong>Off<\/strong>\u201d.<\/li><\/ol>\n\n\n\n<p>In addition, we can do this via SSH as well:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/scripts\/smtpmailgidonly off<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>phpmailer smtp gmail<\/p>\n","protected":false},"author":1,"featured_media":303,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[195,196,194,42,192,197,193],"class_list":["post-302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-and-mysql","tag-command-failed","tag-error-password","tag-gmail","tag-php","tag-phpmailer","tag-sending-email","tag-smtp"],"_links":{"self":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":1,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions\/304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/media\/303"}],"wp:attachment":[{"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/basicwebsitesolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}