Search code examples
asp.netsmtpoffice365smtp-auth

Error while using Office365 SMTP in Asp.Net


I am using Office365 web app SMTP to send email from Asp.Net but Its always throwing following error!

System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated at System.Net.Mail.MailCommand.CheckResponse

The web.config is given below - with username & password changed

<network enableSsl="true"  host="pod51007.outlook.com" userName="XXXX" password="XXXXX" port="587" defaultCredentials="false" />

Solution

  • I think the error message is misleading (as with most Microsoft errors!) - The error code looks very simular to a SMTP error and 5.7.1 is a relay error. You may need to specify your development/production public IP address using the admin portal provided by Microsoft.