smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
582 stars 178 forks source link

SendAsnyc not working #3

Closed southofmarket closed 13 years ago

southofmarket commented 13 years ago

Send() works great, but the page hangs while it tries to connect to the mail server. However, when I try SendAsynch(), it does not throw any errors, but I never receive the email.

smsohan commented 13 years ago

If send works, I think the send async should also work. To double check, you can enable the specifiedPickupDirectory options instead of actual smtp. This will dump your email into the directory. Can you please verify if that works?

southofmarket commented 13 years ago

I tried your suggestion and get this error: The SMTP host was not specified. // send email Line 429: UserMailer.Welcome("test@yahoo.com", "Nancy").SendAsync();

Here are my settings. I commented out step 1 and uncommented step 2:

  <!-- Method#1: Configure smtp server credentials -->
  <!--<smtp from="some-email@gmail.com">
    <network enableSsl="true" host="smtp.gmail.com" port="587" userName="sfuptown@gmail.com" password="3rd&amp;Market" />
  </smtp>-->
  <!-- Method#2: Dump emails to a local directory -->

        <smtp from="some-email@gmail.com" deliveryMethod="SpecifiedPickupDirectory">
            <specifiedPickupDirectory pickupDirectoryLocation="F:\temp"/>
        </smtp>
southofmarket commented 13 years ago

ok, settings for drop are

I tested it with SendAsynch and it works. However it doesn't work when relaying through google. Any ideas on why? This worries me because I don't know if it would work on the deployed site.

Thank you

smsohan commented 13 years ago

I am looking into this issue. Please keep in touch.

smsohan commented 13 years ago

I confirm that the SendAsync wasn't working when using a real smtp host, for example gmail. Reason: The code had a using block around the SmtpClient instance so that Dispose was called. However, since this is SendAsync, the using block marks the client as disposed and thus the email is not sent resulting in Cancelled = true Fix: Get rid of the using block from SendAsync and put it inside the Completed event handler. Now it works fine. Release: Will be released with V 1.0 on Mar 7, 2010.

southofmarket commented 13 years ago

Thank you for the quick response to this issue. :) I look forward to the new release today. Do I simply use nuget to pull down the new release when its available?

Many Thanks

smsohan commented 13 years ago

MvcMailer 1.0 is already released. You can update your copy using Package Manager.