2017-05-22 22 views
0

我想使用HostGator使用Parallels Plesk Panel 11.5在ASP.NET C#MVC 5中創建一個Web應用程序。ASP.NET用Parallels Plesk Panel發送電子郵件11.5

這可能嗎?我希望我的網絡應用程序在有人填寫特定表單時發送電子郵件。我可以在哪裏找到SMTP服務器信息?我需要知道什麼來設置它?

我會很感激任何其他幫助,鏈接或指導,你可以提供,因爲我設置了。

謝謝。

回答

0

這可能太晚了,但幫助其他人;

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