SOLVED
Home

Unable to send SMTP using mailx

Highlighted
Phillip Nguyen
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://smtp.office365.com:25 \
-S from="myname@mydomain.com" \
-S smtp-auth-user="myname@mydomain.com" \
-S smtp-auth-password="password" \
-S ssl-verify=ignore \
myname2@mydomain2.com 

 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 smtp.office365.com with resolved IP address

- Port 25 with port 587

Substitute smtp-auth-user="myname@mydomain.com" with smtp-auth-user="mydomain.com\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 = "myname@mydomain.com"
$to = "myname2@mydomain2.com"
$body = “Just a test email”
$smtp = "smtp.office365.com"
$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
Highlighted

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

 

 

Highlighted
Solution

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.

Related Conversations
A problem with the Zoom level of a Tab
Tavory in Discussions on
9 Replies
Changing Outlook 365 smtp/pop settings
rawbar in Office 365 on
1 Replies
Different From Address Display Name
Shahid Roofi Khan in Office 365 on
1 Replies