I am trying to use my outlook SMTP settings in our web application to send mail to users. The mail is not reaching any of the recipients, but I also don't receive any application errors. I am configuring the mail settings in web.config as below:
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="false" host="smtp.office365.com" port="587" userName="[email protected]" password="SuperSecret123(not real)" enableSsl="true"/>
</smtp>
The code that sends the mail message is like this:
var C = new SmtpClient();
var M = new MailMessage(ConfigurationManager.AppSettings["fromemail"],to,subject,message);
M.IsBodyHtml = true;
C.Send(M);
ConfigurationManager.AppSettings["fromemail"] is the same as my from mail address. All passed variables are what they should be. If I swap out my mail settings for a test gmail account, it works. This leads me to assume that I am being spammed, but I can't confirm this because none of my test mail accounts have the messages in the spam folder, so I assume they're getting nuked on the outlook server BEFORE they're sent.
In addition, I am using a GMail account to test, so I can't really go ahead and use an Office 365 specific solution.