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
587with 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.