Configuring In Web.config To Send Email

Configure the Section of web.config

To send enquiry form emails from your ASP.NET website, you need to configure the section of your web.config file with your SMTP server details.

Step-by-Step Instructions

  1. Open your website’s web.config file in a text editor.
  2. Locate or add the section.
  3. Insert the block with your SMTP details.
  4. Substitute your own email address, domain, and password for the placeholders.
  5. Save the file and upload it to your website.

Example Configuration

<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>

Notes

  • Replace email@yourdomain.com with your actual email address.
  • Replace mail.yourdomain.com with your actual mail server hostname (e.g. mail.plesk-secure.com).
  • Replace youremailpassword with the correct password for your email account.
  • Port 25 is shown here, but you may need to use 465 (SSL/TLS) or 587 (STARTTLS) depending on your server settings.
ℹ Tip: Always use SSL/TLS or STARTTLS if your mail server supports it, to keep your credentials secure.
✔ Recommended: Test your enquiry form after configuration to confirm emails are being sent successfully.
Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 7537

Need more information or have a question ?