SMTP Authentication Failure

Hi,

I have successfully set MIAB on Ubuntu 18.04, I intend to use it as an external SMTP solution. However I am having issue with SMTP authentication.

Scenario;

Server: box.example.com
Email: demo@example.com
Pass: password

I can login successfully to webmail at

box.example.com/mail

and without any issue, can send/receive emails.

However, I am trying to send email from external server using PHPMailer and it’s failing at SMTP authentication, following are settings;

$mail->Host  = 'box.example.com';  
$mail->SMTPAuth   = true;          
$mail->Username   = 'demo@example.com';         
$mail->Password   = 'password';                  
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;    
$mail->Port   = 587;             

Here is PHPmailer’s debug log;

2020-04-25 10:52:18 CLIENT -> SERVER: AUTH LOGIN
2020-04-25 10:52:18 SMTP INBOUND: "334 VXNlcm5hbWU6"
2020-04-25 10:52:18 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2020-04-25 10:52:18 CLIENT -> SERVER: ZGVtb0ByYXpmYS5jb20=
2020-04-25 10:52:18 SMTP INBOUND: "334 UGFzc3dvcmQ6"
2020-04-25 10:52:18 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2020-04-25 10:52:18 CLIENT -> SERVER: UEBraXN0QG4xQDM=
2020-04-25 10:52:20 SMTP INBOUND: "535 Incorrect authentication data"
2020-04-25 10:52:20 SERVER -> CLIENT: 535 Incorrect authentication data
2020-04-25 10:52:20 SMTP ERROR: Password command failed: 535 Incorrect authentication data
SMTP Error: Could not authenticate.
2020-04-25 10:52:20 CLIENT -> SERVER: QUIT
2020-04-25 10:52:20 SMTP INBOUND: "221 srv.example.com closing connection"
2020-04-25 10:52:20 SERVER -> CLIENT: 221 srv.example.com closing connection
2020-04-25 10:52:20 Connection: closed
SMTP Error: Could not authenticate.
Message could not be sent. Mailer Error: SMTP Error: Could not authenticate.

I am wondering same email credentials work for webmail, but not working for external SMTP authentication. am I missing something?

Any help is highly appreciated.

@alyas

Are there any special symbols in the password? Specifically ' ?

Everything points to your PHP app not sending the correct authentication details … so be sure that server is using en_US and UTF-8, etc.

This is a long shot, but also be sure that you are using the absolute most recent versions of your software. Some TLS versions were recently (in the past month) depreciated and MiaB will not accept them any longer … but your error message is not indicative of that being the issue.

@alento
Thanks for your response.

There are no special characters in the password…

However, I had certificate error earlier which I bypassed by using

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

Right now, it’s stuck at SMTP credentials validations.

Any more hints please?

@alyas

No, other than I would figure out the certificate error, rather than bypassing it.

You showed the logs from your app, but what are the MiaB logs showing?

@alento

MiaB log /var/log/mail.log? I don’t get any hit in mail.log for SMTP try.

Am I looking at wrong log file?

Hmm, sounds like you have a completely different issue then …

To help you further I’d need to know your real MiaB hostname, as well as the real settings you are using in your app. Feel free to join me on Slack or communicate via PM here.

As you are a new poster here, I would recommend joining the slack channel.

https://mailinabox.email/slack

@alento

I am grateful for your support, just started conversation on Slack.

An update for anyone stumble upon this thread.

My issue was related to DNS where my test application wasn’t even hitting to my MiaB (since I had a local DNS entry for the box.mymailserver.com domain, and it was considering that mailserver is on the same server as of test phpmailer script).

Once I tested it externally, it was all fine.

Special thanks to @alento for figuring this out.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.