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

Doesn't work with native smtp client #178

Open
erhan355 opened this issue Aug 18, 2022 · 0 comments
Open

Doesn't work with native smtp client #178

erhan355 opened this issue Aug 18, 2022 · 0 comments

Comments

@erhan355
Copy link

Hi ,
I am using version 9.0.1 before upgrading to that version I haven't faced with any issue.It seems now It doesn't work with native smtp client anymore.

Here is my config
var options = new SmtpServerOptionsBuilder()
.ServerName(_smtpSettings.Server)
.Endpoint(
endpointBuilder =>
{
endpointBuilder.Port(9028, false).AllowUnsecureAuthentication(true).AuthenticationRequired();

            }
        ).Build();
    serviceProvider.Add(new SampleUserAuthenticator());
    var server = new smtp.SmtpServer(options, serviceProvider);

Smtp client code

var client = new SmtpClient
{
Port = 9028,
Host = "localhost",
UseDefaultCredentials = false,
DeliveryMethod= SmtpDeliveryMethod.Network
};
client.Credentials = new NetworkCredential("test", "test");

    var mail = new MailMessage
    {
        From = new MailAddress("assda@asda.com"),
        Subject = "Smtp Server Test",

        Body = "Smtp Server Test",

        IsBodyHtml = true
    };

    mail.To.Add(new MailAddress("xx@gmail.com"));

    //CreateAttachments(mail);
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.Send(mail);
    return Task.CompletedTask;

Never hitting SampleUserAuthenticator and gives following error

System.Net.Mail.SmtpException: 'The SMTP server requires a secure connection or the client was not authenticated. The server response was: authentication required'

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

1 participant