Cannot send SMTP mail

  • Thread starter Thread starter JT2019
  • Start date Start date
J

JT2019

Guest
Hi There:

I had a web application that used exchange server to send SMTP mail to acknowledge the process. Lately our company upgraded mail server to office365. I change the code to use below:

SmtpServer.UseDefaultCredentials = False

SmtpServer.Host = "smtp.office365.com"
SmtpServer.Credentials = New Net.NetworkCredential("myemail@officeemail.com", "mypass")
SmtpServer.TargetName = "STARTTLS/smtp.office365.com"
SmtpServer.Port = 587
SmtpServer.EnableSsl = True
Mail = New MailMessage()
mail.From = New MailAddress("myemail@officeemail.com")
mail.To.Add("toEmail@officeemail.com")
Mail.Subject = "Test Mail"
mail.Body = "testing SMTP mail from outlook365"

SmtpServer.Send(mail)


Strangely I was able to send email via my developer's pc but once I published to our hosting server, smtp from office 365 is not working. I caught the error message as follows:

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 [YTXPR0101CA0066.CANPRD01.PROD.OUTLOOK.COM]

I have been spending lots of time trying to solve this. If anyone can give a hand to point out what should I do to confure server or change the code. That would be really appreciate.

Thank you.

Joy

Continue reading...
 
Back
Top