我想使用 Parallels Plesk Panel 11.5 使用 HostGator 在 C# MVC 5 ASP.NET 中创建 Web 应用程序。
这可能吗? 我希望我的网络应用程序在有人填写特定表单时发送电子邮件。 我在哪里可以找到SMTP服务器信息? 我需要知道什么才能设置它?
我将不胜感激您在设置时可以提供的任何其他帮助、链接或指南。
谢谢。
这可能为时已晚,但要帮助其他人;
public static void SendEmail(string toEmail, string subject, string body)
{
try
{
const string fromEmail = "yourEmail@YourDomain.com";
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("yourEmail@YourDomain.com", "your email password");
smtpClient.Port = 25;
smtpClient.EnableSsl = false;
smtpClient.Send(message);
}
}
catch (Exception excep)
{
//ignore it or you can retry .
}
}
这在 Plesk Onyx 17.5.3 上对我有用