andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 168 forks source link

Using Postal on Azure with Sendgrid #130

Open Andreas75 opened 9 years ago

Andreas75 commented 9 years ago

Hi, i'm trying to use Postal on a web app hosted in Azure. But get this error: System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.

This is the code i'm using:

dynamic email = new Email("Test"); email.To = "myEmail@gmail.com"; System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("azure_d3e****b5e@azure.com", "7N******5C"); SmtpClient smtpClient = new SmtpClient("smtp.sendgrid.net", Convert.ToInt32(587)); smtpClient.Credentials = credentials; email.Send();

My Test view:

To: myEmail@gmail.com From: test@test.com Subject: Important Message

Hello, This is a tests!!

My web.config smtp settings:

tbasallo commented 8 years ago

I use Postal with SendGrid in Azure (Web Apps). The only thing I changed was in the web.config.

 <mailSettings>
  <smtp from="noreply@estrellainsurance.com" deliveryMethod="Network">
    <specifiedPickupDirectory pickupDirectoryLocation="c:\email" />
    <network host="smtp.sendgrid.net" port="587" userName="{username}" password="{password}" />
  </smtp>
</mailSettings>

And then I just dynamic e = new Email("view"); e.Send();

However, in your code, you have an SMTP client you instantiated, but you didn't do anything with it. Not sure if it was a copy & paste error. But, if there's nothing in your config, that would never work.