這可能太晚了,但幫助其他人;
public static void SendEmail(string toEmail, string subject, string body)
{
try
{
const string fromEmail = "[email protected]";
var message = new MailMessage
{
From = new MailAddress(fromEmail),
To = { toEmail },
Subject = subject,
Body = body,
DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
};
using (SmtpClient smtpClient = new SmtpClient("webmail.YourDomain.com"))
{
smtpClient.Credentials = new NetworkCredential("[email protected]", "your email password");
smtpClient.Port = 25;
smtpClient.EnableSsl = false;
smtpClient.Send(message);
}
}
catch (Exception excep)
{
//ignore it or you can retry .
}
}
這個工作對我的的Plesk瑪瑙17.5.3