Configuring In Web.config To Send Email

How to Configure <mailSettings> in web.config to Send Emails

To send enquiry form emails from your ASP.NET website, you need to configure the <mailSettings> section in your web.config file. Below is a basic example using SMTP authentication:

<configuration>
  <system.net>
    <mailSettings>
      <smtp from="email@yourdomain.com">
        <network host="mail.yourdomain.com" port="25" 
                 userName="email@yourdomain.com" 
                 password="youremailpassword" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>
      

Replace the highlighted values with your actual email address, SMTP server, and credentials. This setup enables your website to send emails—such as contact form submissions—via your domain’s mail server.


Tips for Reliable Email Delivery

  • Ensure your SMTP server allows relay from your website’s IP address
  • Use port 587 with TLS if your provider requires encryption
  • Set up SPF, DKIM, and DMARC records to improve deliverability
  • Test with a simple form before deploying to production

Need help setting up your enquiry form or troubleshooting SMTP errors? Contact our support team.

Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 10053

Need more information or have a question ?