How send email via Office365 SMTP

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
3/23/2018 5:54:31 AM
Gravatar
Total Posts 533
feet planted firmly on the ground

How send email via Office365 SMTP

A client would like to send emails from their mojoPortal site using Office365 SMTP.

This is documented here: https://support.office.com/en-us/article/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-office-365-69f58e99-c550-4274-ad18-c805d654b4c4 

This is not working for us, trying settings like the following:

<add key="SMTPServer" value="smtp.office365.com" />
<add key="SMTPRequiresAuthentication" value="true" />
<add key="SMTPUseSsl" value="true" />
<add key="SMTPPort" value="587" />
 <add key="SMTPUser" value="a@b.com" />
<add key="SMTPPassword" value="xxxxxxxx" />

or

<add key="SMTPServer" value="smtp.office365.com" />
<add key="SMTPRequiresAuthentication" value="true" />
<add key="SMTPUseSsl" value="true" />
<add key="SMTPPort" value="25" />
<add key="SMTPUser" value="a@b.com" />
<add key="SMTPPassword" value="xxxxxxxx" />

We get this in the error log:

2018-03-23 10:29:56,567 ERROR xx.xx.xx.xx - en-GB - /contact-us - mojoPortal.Net.Email - all retries failed sending email to a@b.org.uk from a@b.com, message was: Crispin<br />xxxxxx@esdm.co.uk<br /><br /><p>test</p>
<br /><br />HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299<br />REMOTE_HOST: xx.xx.xx.xx<br />REMOTE_ADDR: xx.xx.xx.xx<br />LOCAL_ADDR: xx.xx.xx.xx<br />
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [DB6PR0501CA0047.eurprd05.prod.outlook.com]
   at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
   at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
   at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at mojoPortal.Net.Email.Send(SmtpSettings smtpSettings, MailMessage message)

 

I'm suspecting the mojoPortal code possibly doesn't support TLS1.0 or above? Is that it, or could it be something else?

thanks!

 

3/25/2018 2:28:57 PM
Gravatar
Total Posts 533
feet planted firmly on the ground

Re: How send email via Office365 SMTP

Just to add... I have successfully sent via Office365 from a different site using a personal Office365 account and settings like this

<add key="SMTPServer" value="smtp.office365.com" />
<add key="SMTPRequiresAuthentication" value="true" />
<add key="SMTPUseSsl" value="true" />
<add key="SMTPPort" value="587" />
 <add key="SMTPUser" value="a@b.com" />
<add key="SMTPPassword" value="xxxxxxxx" />

This site is running 2.5.0.0

The site that is failing to send is running an older version, 2.4.1.0 (but upgrading is not a simple option unless we know for sure this will solve the emailing issue).

 

3/26/2018 11:43:45 AM
Gravatar
Total Posts 2202

Re: How send email via Office365 SMTP

Hi Crispin,

I wonder if the problem is related to the TLS version being used by your site. Are these sites on the same server?

Also, check the "Default Email From Address" setting in Site Settings. Be sure you're using the same address that is used by SMTPUser setting in the web.config (or the SMTPUser has rights to "send as" the Email From address).

Thanks,
Joe

3/26/2018 5:23:00 PM
Gravatar
Total Posts 533
feet planted firmly on the ground

Re: How send email via Office365 SMTP

Hi Joe

I've certainly tried with the "from" address set as the email for the Office365 account.

TLS version... not sure. The sites are on different servers, but both Server 2008R2 fully patched, and I'm not aware of any difference in this respect. What should I be looking for?

 

3/27/2018 4:37:15 AM
Gravatar
Total Posts 533
feet planted firmly on the ground

Re: How send email via Office365 SMTP

I have also successfully sent from a mojoPortal 2.4.1.0 installation. This is running on the same server as the 2.5.0.0 site where it succeeded.

So, it's either some difference between the two servers, or something wrong with the client's Office365 account or configuration.

Next test - try the client site using one of our Office365 accounts that worked above...

 

3/27/2018 8:54:38 AM
Gravatar
Total Posts 2202

Re: How send email via Office365 SMTP

Try running IISCrypto on the server and enable the "best practices" template. That will disable the obsolete ciphers and protocols. This will cause a reboot. I'm not sure that's the problem but having it out of the way will help troubleshooting.
3/27/2018 8:59:59 AM
Gravatar
Total Posts 533
feet planted firmly on the ground

Re: How send email via Office365 SMTP

Already done!

I have now found that the client site CAN send email using my own Office365 account, so the issue is clearly not in mojoPortal or our server, it must be something to do with the Office365 config or the particular account.

So for the record, mojoPortal 2.4.1.0 and later can definitely send email using Office365 SMTP, which is nice to know.

 

3/27/2018 9:05:07 AM
Gravatar
Total Posts 2202

Re: How send email via Office365 SMTP

Good to hear. Have fun with the office 365 admin portal!
You must sign in to post in the forums. This thread is closed to new posts.