Unable to send email from php script: Error: authentication failed: encryption needed to use mechanism

Created:

2016-12-18 06:52:22 UTC

Modified:

2017-08-08 13:42:27 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Unable to send email from php script: Error: authentication failed: encryption needed to use mechanism

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk 12.0 for Linux

Symptoms

1. Unable to send email from php script:

SMTP -> FROM SERVER:220 vps.ovh.net ESMTP Postfix (Ubuntu)
SMTP -> FROM SERVER: 250-vps.ovh.net 250-PIPELINING 250-SIZE 51200000 250-ETRN 250-STARTTLS 250-AUTH DIGEST-MD5 CRAM-MD5 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
SMTP -> ERROR: AUTH not accepted from server: 535 5.7.8 Error: authentication failed: encryption needed to use mechanism
SMTP -> FROM SERVER:250 2.0.0 Ok

Fatal error: Uncaught exception 'phpmailerException' with message 'SMTP Error: Could not authenticate.' in /var/www/vhosts/example.com/httpdocs/smtp_test/class.phpmailer.php:872 Stack trace: #0 /var/www/vhosts/example.com/httpdocs/smtp_test/class.phpmailer.php(763): PHPMailer->SmtpConnect() #1 /var/www/vhosts/example.com/httpdocs/smtp_test/class.phpmailer.php(630): PHPMailer->SmtpSend('Date: Wed, 14 D...', '--b1_d889ba3b29...') #2 /var/www/vhosts/example.com/httpdocs/smtp_test/class.phpmailer.php(575): PHPMailer->PostSend() #3 /var/www/vhosts/example.com/httpdocs/smtp_test/test.php(80): PHPMailer->Send() #4 {main} thrown in /var/www/vhosts/example.com/httpdocs/smtp_test/class.phpmailer.php on line 872
[/code]

Attempt to connect via telnet results in the following:

# telnet vps1.ovh.net 25
Trying 1.2.3.4...
Connected to vps1.ovh.net.
Escape character is '^]'.
220 vps1.ovh.net ESMTP Postfix (Ubuntu)
auth login
535 5.7.8 Error: authentication failed: encryption needed to use mechanism
quit
221 2.0.0 Bye

2. Unable to setup mail account as an additional account for Gmail in Gmail account > Settings > Accounts and Import > Check mail from other accounts :

Authentication failed. Please check your username/password

The following errors are logged at the same time:

warning: SASL authentication failure: no secret in database
warning: mail-ua0-f171.google.com[209.85.217.171]: SASL CRAM-MD5 authentication failed: authentication failure

Cause

Incorrect configuration if postfix configuration file.

Resolution

Make sure that the following line is commented in /etc/postfix/main.cf :

#smtpd_sasl_security_options = noplaintext

Restart postfix service:

# service postfix restart
Have more questions? Submit a request
Please sign in to leave a comment.