Easy Steps To Authenticate Sending Asp.Net Application Mail on Windows Plesk Server
How To Authenticate Asp.Net Application Mail On A Windows Plesk Server
- Log into your Plesk account. (We are assuming you have already added your website domain in Plesk as if not, add it now and get your DNS working for your website with your MX records. DNS changes can take 24 hours to propagate ) Click on the Mail menu on left of your plesk screen and click on the Add mail account. Set up a new email account that will be the FROM address for your ASP.NET application mail. Keep track of the password. After completing this step, you will see the new email account in your Plesk screen. On the far right of that new email account is an ICON to open up webmail. Click on it and you enter Plesk’s webmail client. Enter the email account, password and select POP3 dropdown and send a test email to another email account of yours and reply back to make sure this new email account is working before going to the next step.
- Add the following code to your asp.net web site page to send application mail (reminder to add: “using Net.Mail;” (without the quotes) at the top of your .cs asp.net file for declaration). Code below is a C# sample to test. Later you can pass in the form variables into the subject and body from your separate WEBFORM.aspx webpage along with the SEND TO email address of who you are sending the email to. In the 2nd line of sample code below, yourdomain is your website’s Plesk domain that matches to your new email account domain you set up in the first step above. Always authenticate Asp.Net Application Mail with the username and password of application emails using the Plesk FROM email address you set up in the above step. Password has to match in this 3rd line in the sample code below.
The c# code below for your aspx.cs file is for testing as you would obviously add code to tell the web user mail has been sent given the code below is executed properly. Get this test code working below first before finishing off your WebForm with all its fields that you want to pass into the subject and body of the email.
SmtpClient mailer = new SmtpClient();
mailer.Host = “mail.yourdomain.yourdomainextension”;
mailer.Credentials = new System.Net.NetworkCredential(“EmailAddressYouSetUpInPleskThatMatchesYourDomainName”, “PleskEmailPasswordYouSetUpForThisEmailID”);
MailMessage MyMail = new MailMessage();
string strSenderName = “Your Name Or Business”;
string strReceiverName = “Some Receiver Name”;
string strMailFrom = “EmailAddressYouSetUpInPleskThatMatchesYourDomainName”;
string strMailTo = “LegitamateEmailAddressHere”;
MyMail.Subject = “Your email subject”;
MyMail.Priority = MailPriority.High;
MyMail.Body = “The content or body text of your email”;
MyMail.From = new MailAddress(strMailFrom, strSenderName);
MyMail.To.Add(new MailAddress(strMailTo, strReceiverName));
catch (Exception error)
// catch to debug your code looking at error description
How We Can Help
Sozo Hosting has been a leader in hosting solutions since 2001 and can assist you in your server needs. Whether you need a cloud server (see specials on this Windows Cloud Hosting Plans link) or a Shared Windows Hosting Plan , we are here to provide you Managed Hosting and Managed Services to fit your budget! Please click on this contact link Contact Us for more information.