Setup smtp client for gmail in asp.net 4
Asp.net 4 provides a nice feature that you can setup you smtp client for those providers requiring ssl secure connection. Taking gmail for an example, if you are setting the smtp through web.config file at the root of your website, it should look like this:
<configuration>
……
<system.net>
<mailSettings>
<smtp deliveryMethod=”Network” from=”name <yourname@gmail.com>”>
<network enableSsl=”true” host=”smtp.gmail.com” password=”yourpassword” userName=”username@gmail.com” port=”587″/>
</smtp>
</mailSettings>
</system.net>
</configuration>
So the enableSsl=”true” allows the SSL connection and you need to write out explicitly the right port number, 587 in this case (I tried 465 or leave it blank. In both cases, the smtp doesn’t work properly.).
A quick reminder: you can always set the deliveryMethod = “SpecifiedPickupPlace” to send email to local folder during development time
今天你菊子曰了么?