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

Missing SMTP host exception despite using SpecifiedPickupDirectory #31

Open
JustinStolle opened this issue Dec 3, 2011 · 2 comments
Open

Comments

@JustinStolle
Copy link

When using SpecifiedPickupDirectory as the deliveryMethod in Web.config for testing (rather than Network with a host value), an InvalidOperationException is thrown with the message "The SMTP host was not specified."

at System.Net.Mail.SmtpClient.CheckHostAndPort()
at System.Net.Mail.SmtpClient.get_ServicePoint()
at System.Net.Mail.SmtpClient.Dispose(Boolean disposing)
at System.Net.Mail.SmtpClient.Dispose()
at Mvc.Mailer.SmtpClientWrapper.Send(MailMessage mailMessage)
at Mvc.Mailer.MailMessageExtensions.Send(MailMessage message, ISmtpClient smtpClient)
at MySite.Controllers.UsersController.ResetPassword(String userName)

@JustinStolle
Copy link
Author

The message does get "sent" to the specified pickup directory even though this error is thrown, but I'd prefer not to have to catch an InvalidOperationException just to ignore it.

@JustinStolle
Copy link
Author

The workaround to this bug (that is closed as fixed, see this item) is to add <network host="localhost" /> (using "localhost" or any other value) to Web.config, but I'm curious if you think adding any handling code to the overridden Send method in SmtpClientWrapper class would be advised.

<system.net>
  <mailSettings>
    <smtp from="notify@domain.com" deliveryMethod="SpecifiedPickupDirectory">
      <specifiedPickupDirectory pickupDirectoryLocation="C:\temp\EmailPickup\" />
      <network host="localhost" />
    </smtp>
  </mailSettings>
</system.net>

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