var fromAddress = new MailAddress("admin@mydomain.com");
var toAddress = new MailAddress("example@gmail.com");
const string fromPassword = "xxxxxxxxx";
string subject = "test";
string body = "test text";
var smtp = new SmtpClient
{
Host = "mail.mydomain.com",
Port = 25,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(<a user account with administrator role created in plesk>, <the user's password>)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}