Most ASP.NET sites need to send email: contact-form notifications, order confirmations, password resets. On Domain India Windows hosting your app sends through a mailbox you create in Plesk, over an encrypted SMTP connection. This tutorial covers the app side: which settings to use, which .NET library works with them, and how to keep the password out of your code.
Create a mailbox in Plesk, then have your app send through mail.yourdomain.com on port 465 with SSL/TLS, logging in with the full email address and its password. Port 587 is closed on Windows hosting. .NET's built-in SmtpClient cannot use port 465, because it doesn't support implicit TLS, so use the MailKit library. Store the SMTP password in configuration, never in source code.
Mailbox creation, webmail and mail app settings are covered in Setting up email accounts in Plesk. This article starts once you have a mailbox for your app to send from.
1. Create a mailbox for your application
In Plesk, open Mail and click Create Email Address. A dedicated address such as [email protected] or [email protected] works well:
- it keeps app mail separate from people's inboxes;
- you can change its password without disturbing anyone;
- replies and bounces land in one place you can check.
Give it a long, random password. You will paste it into your app's configuration once, not type it again.
2. The SMTP settings your app needs
| Setting | Value |
|---|---|
| SMTP host | mail.yourdomain.com |
| Port | 465 |
| Security | SSL/TLS from the start of the connection (implicit TLS) |
| Username | The full email address, such as [email protected] |
| Password | That mailbox's password |
| From address | The same mailbox, or another address on your domain |
Many code samples use port 587 with STARTTLS. On Domain India Windows hosting that port is not open, so the connection times out. Use 465 with SSL/TLS. The full port list is in Domain India web hosting port numbers.
3. Why System.Net.Mail doesn't work on port 465
The classic System.Net.Mail.SmtpClient class, and the system.net/mailSettings section in web.config that feeds it, support only STARTTLS: the connection starts unencrypted and upgrades. Port 465 expects encryption from the very first byte, which SmtpClient does not support. Microsoft also recommends against SmtpClient for new development and points to MailKit instead.
So on Windows hosting, send with MailKit, a free open-source library available on NuGet:
dotnet add package MailKit4. Sending mail with MailKit
This works in ASP.NET Core and in .NET Framework 4.x projects:
using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Your Site", "[email protected]"));
message.To.Add(new MailboxAddress("", "[email protected]"));
message.Subject = "Thanks for your enquiry";
message.Body = new TextPart("plain") { Text = "We received your message." };
using var client = new SmtpClient();
await client.ConnectAsync("mail.yourdomain.com", 465, SecureSocketOptions.SslOnConnect);
await client.AuthenticateAsync("[email protected]", smtpPassword);
await client.SendAsync(message);
await client.DisconnectAsync(true);SecureSocketOptions.SslOnConnect is the setting that matches port 465. Note that this SmtpClient is MailKit's class, not the one from System.Net.Mail.
5. Keep the password out of your code
Read the SMTP settings from configuration instead of hard-coding them.
ASP.NET Core, in appsettings.Production.json or as environment variables in web.config:
{
"Smtp": {
"Host": "mail.yourdomain.com",
"Port": 465,
"User": "[email protected]",
"Password": "set-on-the-server-only"
}
}.NET Framework, in the appSettings section of web.config, read with ConfigurationManager.AppSettings.
Never commit the real password to Git. Keep a placeholder in the repository and put the real value only in the file on the server.
6. Make your mail land in the inbox
- Send from your own domain. A From address at Gmail or another provider, sent through your hosting, will fail SPF checks and be marked as spam.
- Keep the DNS records. When your domain uses the hosting nameservers, Plesk publishes MX, SPF, DKIM and DMARC records. If your DNS is elsewhere, copy them across, as described in Setting up email accounts in Plesk.
- Use Reply-To for visitor addresses. For a contact form, send from your mailbox and put the visitor's address in
ReplyTo, never inFrom. - Don't send bulk mail. Hosting mailboxes are for your site's own messages. Use a dedicated newsletter service for marketing lists.
7. Reading mail from your app
If your app must read a mailbox, for example to import replies, MailKit's ImapClient connects to mail.yourdomain.com on port 993 with SecureSocketOptions.SslOnConnect, using the same username and password.
8. Testing and troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Timeout when connecting | Port 587 in your settings | Use 465 with SslOnConnect |
| "Authentication failed" | Short username or wrong password | Use the full email address; reset the mailbox password in Plesk |
| SSL or certificate error | Certificate name doesn't match the host | Include mail in your Let's Encrypt certificate, or ask support which host name to use |
| Sent, but lands in spam | From address not on your domain, or missing SPF/DKIM | Send from your own domain; check the DNS records |
Test by sending to a mailbox you control on another provider, and check the spam folder too. More: I can receive mail but I cannot send it.
9. Where Domain India fits
Every Windows plan includes email accounts on your domain, managed in Plesk. The cards show live prices, excluding 18% GST.
- 10 GB Storage
- 50 GB Monthly Bandwidth
- 1 Website
- 10 Email Accounts
- 30 GB Storage
- 150 GB Monthly Bandwidth
- 5 Websites
- 50 Email Accounts
If you would rather keep email separate from your hosting, Business Email is priced per mailbox.
Which SMTP settings should my ASP.NET app use on Domain India Windows hosting?
Host mail.yourdomain.com, port 465 with SSL/TLS from the start of the connection, and SMTP authentication with the full email address and the mailbox password.
Why does my app time out when sending on port 587?
Port 587 is not open on Domain India Windows hosting. Use port 465 with implicit SSL/TLS instead.
Can I use System.Net.Mail SmtpClient on port 465?
No. System.Net.Mail.SmtpClient supports only STARTTLS and cannot connect to port 465, which needs TLS from the first byte. Use the MailKit library with SecureSocketOptions.SslOnConnect.
Where should I store the SMTP password?
In configuration on the server, such as appsettings.Production.json, environment variables in web.config, or appSettings for .NET Framework. Never hard-code it or commit it to Git.
Why do my contact-form emails go to spam?
Usually because the From address is the visitor's address or is not on your domain. Send from a mailbox on your own domain, put the visitor in Reply-To, and keep the SPF and DKIM records that Plesk publishes.
Ready to add email to your ASP.NET app? Compare the Windows hosting plans, or open a ticket if your app still cannot send. Support is on 24/7 live chat, and tickets get a first response within 15 minutes.
Mailboxes on your own domain, managed in Plesk, with every Windows plan.
See Windows hosting plans