Serilog email sink, default network credentials

794 Views Asked by At

Smtp client has the following:

    SmtpClient client = new SmtpClient(server);
    client.UseDefaultCredentials = true;

using these credentials I can send emails.

Now when trying to hook Serilog email sink there is no such option, it wants actual username&password:

new EmailConnectionInfo
                    {
                        FromEmail = "",
                        ToEmail = "",
                        MailServer = "",

                        //I want default credentials, not this
                        NetworkCredentials = new NetworkCredential
                        {
                            UserName = "",
                            Password = ""
                        },

                        EnableSsl = false,
                        ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => true,
                        Port = 587,
                        EmailSubject = ""
                    }

Is there a way to make it accept default credentials?

1

There are 1 best solutions below

0
Nick Farsi On

Use port 25 and it will work with null credentials