1 year ago

#383443

test-img

fdkgfosfskjdlsjdlkfsf

Enabling TLS1.2 support in smtp.office365.com (.Net Core 2.0)

We're testing an iPhone app that sends an email to a specific email address. The developer is using Xamarin.Forms. He says it's a class library project for Xamarin.iOS.

When our iPhone app sends an email, we get the following error. The email is sent because I log on to sender@MyCompany.com and I notice that the emails are in the Sent folder:

System.Net.Mail.SmtpException: 421 X.XX.XX TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls. [DXXP273CA0011.AREP273.PROD.OUTLOOK.COM] at System.Net.Mail.SmtpClient.CheckStatus

While researching, I found this question: Sending EMAIL from c# code over office365 returns: TLS 1.0 and 1.1 are not supported by your organization

I implemented the line of code in the question, plus the following snippet. I continue receiving the same message.

ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls |         SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12

How can I enable TLS1.2 support?

He added the following line, but I continue receiving the error: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

I'm still waiting to see if it made a difference.

For what it's worth, I'm also including the code:

void test()
{
    try
    {
        ServicePointManager.Expect100Continue = true;
        ServicePointManager.DefaultConnectionLimit = 9999;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
        MailMessage mail = new MailMessage();
        SmtpClient SmtpServer = new SmtpClient("smtp.office365.com");

        mail.From = new MailAddress("sender@MyCompany.com");
        mail.To.Add("receiver@yahoo.com");
        mail.Subject = "Test Subject";
        mail.Body = "Lorem Ipsum";

        SmtpServer.Port = 587;
        SmtpServer.Credentials = new NetworkCredential("sender@MyCompany.com", "MyPassword");
        SmtpServer.EnableSsl = true;
        SmtpServer.Send(mail);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
}

c#

iphone

xamarin

xamarin.forms

0 Answers

Your Answer

Accepted video resources