Currently, I'm using Redhat distro and I can send emails to Gmail server with sendmail but when I try to use Outlook server it generates the log below in maillog file. (outlook_sender@mydomain send to outlook_receiver@mydomain)
Sep 7 11:23:49 localhost sendmail[12785]: starting daemon (8.14.7): SMTP+queueing@01:00:00
Sep 7 11:23:49 localhost sm-msp-queue[12803]: starting daemon (8.14.7): queueing@01:00:00
Sep 7 11:25:14 localhost sendmail[12902]: 0874PE57012902: from=root, size=219, class=0, nrcpts=1, msgid=<202009070425.0874PE57012902@localhost.localdomain>, relay=root@localhost
Sep 7 11:25:14 localhost sendmail[12903]: 0874PELI012903: from=<root@localhost.localdomain>, size=477, class=0, nrcpts=1, msgid=<202009070425.0874PE57012902@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Sep 7 11:25:14 localhost sendmail[12902]: 0874PE57012902: to=outlook_receiver@mydomain, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30219, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (0874PELI012903 Message accepted for delivery)
Sep 7 11:25:14 localhost sendmail[12905]: STARTTLS=client, relay=xsp-efz.ms-acdc.office.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256/256
Sep 7 11:25:19 localhost sendmail[12905]: 0874PELI012903: to=<outlook_receiver@mydomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:05, xdelay=00:00:05, mailer=relay, pri=120477, relay=xsp-efz.ms-acdc.office.com. [40.100.29.34], dsn=5.0.0, stat=Service unavailable
Sep 7 11:25:19 localhost sendmail[12905]: 0874PELI012903: forward /root/.forward.localhost: World writable directory
Sep 7 11:25:19 localhost sendmail[12905]: 0874PELI012903: forward /root/.forward: World writable directory
Sep 7 11:25:19 localhost sendmail[12905]: 0874PELI012903: 0874PJLI012905: DSN: Service unavailable
Sep 7 11:25:19 localhost sendmail[12905]: 0874PJLI012905: to=<root@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31712, dsn=2.0.0, stat=Sent
Below is the configuration in sendmail.mc file:
define(`SMART_HOST', `[smtp.office365.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/auth/outlook_auth.db')dnl
MAILER(`local')dnl
MAILER(`smtp')dnl
And below is the configuration of outlook_auth file:
AuthInfo:smtp.office365.com "U:root" "I:outlook_sender@mydomain" "P:outlook_password" "M:PLAIN"
When I change the smart_host from smtp.office365.com to smtp.gmail.com, change the outlook_auth file to gmail_auth file like below, map sendmail.mc file to the sendmail.cf file then restart sendmail, it works normally.
AuthInfo:smtp.gmail.com "U:root" "I:gmail_sender@mydomain" "P:gmail_password" "M:PLAIN"
I don't know much about how the SMTP system works, just did some research and configured sendmail yesterday so if you need more information please let me know.
Below is the log in root file (/var/spool/):
Reporting-MTA: dns; localhost.localdomain
Received-From-MTA: DNS; localhost
Arrival-Date: Tue, 8 Sep 2020 09:06:09 +0700
Final-Recipient: RFC822; outlook_receiver@mydomain
Action: failed
Status: 5.7.57
Diagnostic-Code: SMTP; 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [SG2PR06CA0235.apcprd06.prod.outlook.com]
Last-Attempt-Date: Tue, 8 Sep 2020 09:06:14 +0700
--08826EuC010437.1599530774/localhost.localdomain
Content-Type: message/rfc822
Return-Path: <root@localhost.localdomain>
Received: from localhost.localdomain (localhost [127.0.0.1])
by localhost.localdomain (8.14.7/8.14.7) with ESMTP id 088268uC010433
for <outlook_receiver@mydomain>; Tue, 8 Sep 2020 09:06:09 +0700
Received: (from root@localhost)
by localhost.localdomain (8.14.7/8.14.7/Submit) id 088268ti010432
for outlook_receiver@mydomain; Tue, 8 Sep 2020 09:06:08 +0700
From: root <root@localhost.localdomain>
Message-Id: <202009080206.088268ti010432@localhost.localdomain>
Date: Tue, 08 Sep 2020 09:06:08 +0700
To: outlook_receiver@mydomain
Subject: test subject
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
test content.
--08826EuC010437.1599530774/localhost.localdomain--
Best Answer
First, you need to add Partner Connector in the Office365 Exchange Admin center. Then add your server IP address there.
Now in your SendMail MTA Configuration add this
Make sure you replace MX-OF-YOUR-OFFICE365-DOMAIN using your domain Office365 MX.
If you like to use Office365 Auth Client, follow this.
Update Access with Office365 SMTP User ID Pass
Generate hash file using Auth File
Regenerate DB File sudo makemap hash /etc/mail/access.db < /etc/mail/access
After that issue
Try to send mail afterward.