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.
- 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="email@example.com" \-S smtp-auth-user="firstname.lastname@example.org" \-S smtp-auth-password="password" \-S ssl-verify=ignore \email@example.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="firstname.lastname@example.org" 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 = "email@example.com"$to = "firstname.lastname@example.org"$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?
View best response
Just tried with telnet mail from in Windows PowerShell and it is still not working!
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.