Unable to send SMTP using mailx

Occasional Contributor

I am trying to send SMTP email from the Linux mailx command; however, no matter how I try, the return from the server is always Authentication unsuccessful.

I did:

- Setup connector in Office 365 exchange to add my public IP addresses as trust

- Setup an Office 365 account with an Essential subscription

- Allow incoming & outgoing SMTP traffic over port 25 and 587 on my firewall for all Office365's IP addresses

I tried to run:

mailx -v -s "Now is `date`" \
-S smtp-use-starttls \
-S ssl-verify=ignore \
-S smtp-auth=login \
-S smtp=smtp:// \
-S from="" \
-S smtp-auth-user="" \
-S smtp-auth-password="password" \
-S ssl-verify=ignore \ 

 And I always get the return below from the Office365 server.

535 5.7.3 Authentication unsuccessful [YQBPR0101CA0032.CANPRD01.PROD.OUTLOOK.COM]
smtp-server: 535 5.7.3 Authentication unsuccessful [YQBPR0101CA0032.CANPRD01.PROD.OUTLOOK.COM]
"/root/dead.letter" 11/388
. . . message not sent.

 I tried to change the following variables:

- Substitute with resolved IP address

- Port 25 with port 587

Substitute smtp-auth-user="" with smtp-auth-user="\myname"


I also tried to send message with other applications such as Windows PowerShell, APC's PowerChute Business Edition, SMTP Diag Tools, my custom build Java app. And none of them working.

The only case I was able to get it work is thought Windows PowerShell with the exact command

$cred = Get-Credential
$from = ""
$to = ""
$body = “Just a test email”
$smtp = ""
$subject = "Test"
Send-MailMessage -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -SmtpServer $smtp -UseSsl -Credential $cred -Port 25

If I change the port to 587 then it will stop working.


Is there anyone successfully manage to get mailx working with Office365 SMTP?

2 Replies

Just tried with telnet mail from in Windows PowerShell and it is still not working!2018-06-12 13_58_09-.jpg



best response confirmed by Phillip Nguyen (Occasional Contributor)

I found the resolution.

The issue is at the MX record's IP address was not allowed in the firewall.

Also I had to request for IP and domain white listing in the Spamhaus.