Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The server committed a protocol violation The server response was: #341

Open
mostafavb opened this issue Sep 21, 2022 · 1 comment
Open

Comments

@mostafavb
Copy link

mostafavb commented Sep 21, 2022

I am using FluentEmail in Asp.Net project on .netframework 4.8, when I want to use SendAsync method I get this error:

"The server committed a protocol violation The server response was: "

there is nothing anymore to give more information about this error.

`
SmtpSender smtpSender =

        new SmtpSender(() => new System.Net.Mail.SmtpClient("smtp.office365.com")
        {
            EnableSsl = true,
            DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
            Port = 587,
            Credentials = new System.Net.NetworkCredential("[email protected]", "00X-0")
        });

        Email.DefaultSender = smtpSender;
        var email = Email
            .From("[email protected]", "Customer Care")
            .To(toAddresses)               
            .Subject(subject)
            .UsingTemplate(body, new { });           
        try
        {
            var sendedEmail = await email.SendAsync();
            return sendedEmail.Successful;
        }
        catch (Exception ex)
        {
            LogManager.InsertLog(LogTypeEnum.SystemError, "Error sending e-mail for order notification." + ex.Message, ex);
            return false;
        }

`

Screenshot 2022-09-21 085808

@carlin010
Copy link

@mostafavb you could try using FluentEmail.MailKit instead of FluentEmail.Smtp.

FluentEmail.MailKit is the current recommendation from Microsoft and was the only method of getting SMTP over port 587 working. In my case, it seemed like FluentEmail.Smtp could not properly negotiate which SSL / TLS encryption should be used for the connection and caused the same error you are seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants