PHPMailer – SMTP error password command failed

phpmailer smtp gmail

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.

Anyways, hope you enjoyed the research. It helped me through mine.

Leave some comments blow.

Coffee Cup

phpmailer-smtp-error-password-command-failed

Stuck with PHPMailer – SMTP error password command failed? We can help you.

We may come across this error when we try to send mail using phpmailer().

SMTP ERROR: Password command failed: 534-5.7.14

As part of our Server Management Services, we assist our customers with several SMTP queries.

Today, let us see how to fix this error.

PHPMailer – SMTP error password command failed

This error may occur due to the below reasons:

  • When a less secure application tries to use the email account.
  • If we try to log in several times a row
  • 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).

Moving ahead, let us see the methods our Support Techs employ in order to fix this.

Solution 1: In the case of the Windows server

PHP.ini

  1. Initially, we go to C:\xampp\php, edit the php.ini file with notepad.
  2. Under the [mail munction] section, we remove the semicolon for this line:sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”
  3. Then we add a semicolon for this line:sendmail_path=”C:\xampp\mailtodisk\mailtodisk.exe”

SendMail.ini

  1. Here, we go to C:\xampp\sendmail, edit the sendmail.ini file with notepad
  2. Then we change the following:smtp_server=smtp.gmail.com smtp_port=465 [email protected] auth_password=your-gmail-password [email protected]

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

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

  1. Initially, we login to the account via web
  2. Then we view recent attempts to use the account and accept suspicious access:
    https://security.google.com/settings/security/activity?hl=en&pli=1
  3. 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)

  1. Initially, login to the account via web
  2. Access the URL: https://accounts.google.com/b/0/DisplayUnlockCaptcha
  3. Then we click the continue option
  4. 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.

  1. Go to Admin panel >> Security with Shield icon >> Basic settings
  2. Then go to the Less secure apps section
  3. 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.

  1. Firstly, log in to CPanel
  2. Navigate to Tweak Settings > All > “Restrict outgoing SMTP to root, Exim, and mailman
  3. Eventually, switch it from “On” to “Off”.

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

/scripts/smtpmailgidonly off

SB Admin PHP – Fixed Table Header with Scrollable Body

Hi guys,

This question was raised to me recently and it peeked my interest to solve and find out how to do this. After digging around i found 2 working codes for my case.

To explain further my tables are generated dynamically so the column widths and gaps differ by each refresh of the table

There are the 2 options that i found

////////////// OPTION 1 //////////////////////
table tbody { display:block; max-height:450px; overflow-y:scroll; }
table thead, table tbody tr { display:table; width:100%; table-layout:fixed; }

table width=”100%” class=”table table-striped table-hover” id=”dataTables-example”
////////////// OPTION 2 //////////////////////
table {
overflow-y: auto;
height: 10vh;
}
thead th {
position: sticky;
top: 0;
}

table width=”100%” class=”table table-striped table-hover” id=”dataTables-example”

Hope this code helps out somebody out there. If you have any questions, just drop me a line.

Coffee Cup

How to change table row count in the bootstrap website?

I have been working with bootstrap websites for quite some time and making admin backend pages have been a new experience for me.

Lately the default 10 row table data have a lot of people ask if we can increase it to a certain number other than 10.

Fortunately, I came across the code to grant this request. But we need to go into the source code page to accomplish this.

Inside the HTML page, at the bottom, you will see a script section

We need to add more code to it.

When you refresh the page, you will see that it now starts at 50 rows

That’s just about it.

Enjoy,

Coffee Cup

Youtube link is
https://www.youtube.com/watch?v=GdH3IkYBwI4

Automatically Let Google Translate Your Webpage

Let Google translate your webpage

There was a requirement before that the webpage needs to be converted to any language that the guest will be coming from.

So I got digging and found the code that will let Google translate convert it on the fly. Take note that this might need a few web source tinkering.

Here it is :

And the output you will see is :

I’m not sure why I cannot copy and paste code to WordPress for now. I am suspecting that you cannot copy <DIV> statements. But soon I will know why. But for now, a screenshot will do.

Now, of course, there is a downside to using this one. The translation going back from Chinese-to-English for example might not yield the same result. Just be careful if you are using words like Parent’s Portal that might be translated as an intergalactic dimension.

Just to be safe, we can keep it to plain or simple words that google can understand.

As always stay safe

Coffee Cup

You can view the youtube video here :
https://youtu.be/Q0Hqbn-4p6I

PHP tip : how to remove columns and save to another file

Hello guys,

Had a special request to trim the csv fields in the file.

After searching, found a code to satisfy the request.

Posted the URL from the original link

Enjoy,

Coffee Cup

http://stackoverflow.com/questions/8608970/writing-to-csv-using-fgetcsv

$input = 'input.txt';
$output = 'output.txt';

if (false !== ($ih = fopen($input, 'r'))) {
    $oh = fopen($output, 'w');

    while (false !== ($data = fgetcsv($ih))) {
        // this is where you build your new row
        $outputData = array($data[0], $data[1], $data[4], $data[5], $data[6]);
        fputcsv($oh, $outputData);
    }

    fclose($ih);
    fclose($oh);
}