Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Luke Gibson 3 posts 73 karma points
    Dec 07, 2020 @ 14:00
    Luke Gibson
    0

    5.7.3 STARTTLS is required to send mail

    Has anyone had any experience creating basic contact form to send to an office 365 account?

    I am getting the following error when I try to submit the form with the send method as below...

    Error in processing. The server response was: 5.7.3 STARTTLS is required to send mail [LO4P123CA0177.GBRP123.PROD.OUTLOOK.COM]

    My method look like this...

    private void SendEmail(ContactShowroomModel model)
        {
            string userName = "my-username";
            string password = "my-password";
            MailMessage msg = new MailMessage();
            msg.To.Add(new MailAddress("my-email-address"));
            msg.From = new MailAddress(userName);
            msg.Subject = $"Website enquiry from Name: { model.Name} | Email Address: { model.Email}";
            msg.Body = model.Message;
            msg.IsBodyHtml = true;
            SmtpClient client = new SmtpClient();
    
            client.Credentials = new System.Net.NetworkCredential(userName, password);
            client.UseDefaultCredentials = false;
            client.Host = "smtp.office365.com";
            client.EnableSsl = false;
            client.TargetName = "STARTTLS/smtp.office365.com";
            client.Port = 587;
            client.Send(msg);
        }
    
  • Huw Reddick 1932 posts 6722 karma points MVP 2x c-trib
    Dec 07, 2020 @ 18:10
    Huw Reddick
    0

    EnableSsl should be true not false

  • Luke Gibson 3 posts 73 karma points
    Dec 07, 2020 @ 20:58
    Luke Gibson
    0

    This unfortunately just adds to the errors, additional error:

    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 [LO2P265CA0515.GBRP265.PROD.OUTLOOK.COM]

  • Robert Sikkens 7 posts 78 karma points
    Dec 07, 2020 @ 21:57
    Robert Sikkens
    0

    I've no problems using it, maybee you using only username, setting msg.From with a complete email address

  • Luke Gibson 3 posts 73 karma points
    Dec 07, 2020 @ 22:36
    Luke Gibson
    0

    I can't see what I am doing differently to other people

  • Huw Reddick 1932 posts 6722 karma points MVP 2x c-trib
    Dec 08, 2020 @ 05:11
    Huw Reddick
    0

    As per previous persons comment, from should be an email address, is username an email address?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies