Kent J. Chen's WebLog

...information technology, internet, and random thoughts

Saturday, May 03, 2008

Send Authenticated Email in ASP.Net 2.0

To send emails from web form written in ASP.Net 2.0 to an email address that only receives emails from authenticated users, you need to set defaultCredentials="true" in web.config file with other SMTP settings, see below, or the email sent from the form will just go missing without leaving any trace.  For example:

<system.net>
    <mailSettings>
        <smtp deliveryMethod="Network">
            <network host="mailserver" port="25" defaultCredentials="true" />
        </smtp>
    </mailSettings>
</system.net>

Besides, you might also need to set up security authentication impersonate to true as well in web.config file in order to pass the proper authenticated credential to the mail server.

<authentication mode="Windows" />
<identity impersonate="true" />
<authorization>
  <deny users="?" />
</authorization>

For people who don't know how to determine if the email address is set to only receive emails from authenticated users, if you are Microsoft Exchange user, you can easily find out from the following property window.

image

<update>
please see updated post for more updated information.
</update>

posted @ Saturday, May 03, 2008 11:51 PM | Feedback (0) | Filed Under [ Programming ]

My Recent Posts