maoyuan121 / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

ErrorMailModule - Invalid Default DeliveryMethod #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Configure system.net/mailSettings/smtp to use 
deliveryMethod="SpecifiedPickupDirectory"
2.Configure Elmah to use smtpServer

What is the expected output? What do you see instead?
When elham error log is sent it's SmtpClient's DeliveryMethod defaults to 
SpecifiedPickupDirectory and so ignores the smtpServer configuration

What version of the product are you using? On what operating system?
1.2 on x64, Win7 & win 2008

Please provide any additional information below.
This issue can be fixed simply by setting the client.DeliveryMethod = 
SmtpDeliveryMethod.SpecifiedPickupDirectory if the host variable length > 0 in 
the ErrorMailModule.SendMail

    protected override void SendMail(System.Net.Mail.MailMessage mail)
    {
        if (mail == null)
            throw new ArgumentNullException("mail");

        //
        // Under .NET Framework 2.0, the authentication settings
        // go on the SmtpClient object rather than mail message
        // so these have to be set up here.
        //

        var client = new SmtpClient();

        string host = SmtpServer ?? string.Empty;
        if (host.Length > 0)
        {
            client.Host = host;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
        }

        int port = SmtpPort;
        if (port > 0)
            client.Port = port;

        string userName = AuthUserName ?? string.Empty;
        string password = AuthPassword ?? string.Empty;

        if (userName.Length > 0 && password.Length > 0)
            client.Credentials = new NetworkCredential(userName, password);

        client.EnableSsl = UseSsl;

        client.Send(mail);
    }

Original issue reported on code.google.com by dam...@mcgiv.com on 19 May 2011 at 4:49

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 31 May 2011 at 7:41

GoogleCodeExporter commented 9 years ago
Fixed in r894.

Original comment by azizatif on 31 May 2011 at 7:50