Sending Emails from a .NET Application Using a Local SMTP Server
This article contains steps how send e-emails from your website.
ASP.NET / .NET freehosting
If you don't already have our ASP.NET / .NET freehosting, sign up for FREE at https://MonsterASP.net/.
Important: Outgoing SMTP on web hosting is only available with the Premium subscription.
1. Configuring SMTP in .NET (Without Authentication, Port 25)
If you need send e-mails, you can use a local SMTP server that does not require authentication and uses port 25, here’s a basic setup.
Replace siteXXXX.siteasp.net with your actual server hostname (see below).
{
"Smtp": {
"Host": "siteXXXX.siteasp.net",
"Port": 25,
"Username": "",
"Password": "",
"EnableSsl": false
}
2. Finding the SMTP Server Hostname
3. Configuring an SPF Record in DNS
SPF (Sender Policy Framework) tells receiving mail servers which IPs/hosts are allowed to send mail for your domain. It helps prevent spam and increases deliverability.
In our case, the DNS record will look like this:
Name: @
Typ: TXT
Value: v=spf1 a:siteXXXX.siteasp.net ~all
Or if You already have an SPF record (e.g., for Office 365):
Name: @
Typ: TXT
Value: v=spf1 include:spf.protection.outlook.com a:siteXXXX.siteasp.net ~all
4. Securing the Contact Form from Bots and Abuse
If you are using contact form on your website and sends emails via our SMTP server without protection, bots can abuse it to send spam. Recommended Solution is Use CAPTCHA or Cloudflare Turnstile.
CAPTCHA protection
Use Google reCAPTCHA v3 or v2, which can be easily integrated into a .NET application:
https://www.google.com/recaptcha/about/
For ASP.NET MVC / Razor Pages, there are available packages:
reCAPTCHA.AspNetCore
https://www.nuget.org/packages/reCAPTCHA.AspNetCore/