asp.net to Office 365 smtp relay
Posted on 2011-09-25
I currently have an asp.net website that sends emails to my SBS2008 server. I am in the midst of moving my email to office 365. I need to edit the asp.net code to work with office 365 and make sure that office 365 is able to receive emails from my separately hosted website.
Here is the code I have converted so far that does NOT work with Office 365:
Dim client As New SmtpClient
client.Host = "pod???.outlook.com"
client.Port = 587
client.EnableSsl = True
client.Credentials = New NetworkCredential("email address", "password")
This code currently gets the following error:
5 The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
The code above works with my SBS2008 server, but I am missing an important detail to make this work with Office 365. I believe it has something to do with TLS, but I don't see anyother options to modify.
I should also mention that I would like the emails to show they come from the person submitting them from the website, to make it easy to reply to. Making this a smtp relay question and that might mean I require additional configuration changes to my office 365 setup to allow it to accept these types of emails so it doesn't get caught as spam.