2016-07-23 57 views
1

我知道也許我的問題有些奇怪,但我想從asp.net web項目發送電子郵件到我的註冊客戶端。我可以很容易地使用gmail來做到這一點。但我想從Parallels Webmail發送它。 我的C#代碼是這樣的:
Parallels Webmail問題

using (MailMessage mm = new MailMessage("[email protected]", email)) 
      { 
       mm.Subject = "Account Activation"; 
       string body = "Hello " + name.Trim(); 
       mm.Body = body; 
       mm.IsBodyHtml = true; 
       SmtpClient smtp = new SmtpClient(); 
       smtp.Host = "mydomain.com"; 
       smtp.EnableSsl = true; 
       NetworkCredential NetworkCred = new NetworkCredential("[email protected]", "mypassword"); 
       smtp.UseDefaultCredentials = true; 
       smtp.Credentials = NetworkCred; 
       smtp.Port = 26;//587 is also tested 
       smtp.Send(mm); 
     } 

,但我得到的錯誤 「A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.63.251.194:26

我相信我無法發送正確smtp.host格式。
這只是在paralles enter image description here
設置電子郵件客戶端錯誤消息的截屏也在這裏enter image description here

任何意見讚賞。

回答

1

使用端口25,使smtp.EnableSsl = true;

using (MailMessage mm = new MailMessage("[email protected]", email)) 
{ 
    mm.Subject = "Account Activation"; 
    string body = "Hello " + name.Trim(); 
    mm.Body = body; 
    mm.IsBodyHtml = true; 
    SmtpClient smtp = new SmtpClient(); 
    smtp.EnableSsl = false; 
    smtp.Host = "mydomain.com"; 
    NetworkCredential NetworkCred = new NetworkCredential("[email protected]", "mypassword"); 
    smtp.UseDefaultCredentials = true; 
    smtp.Credentials = NetworkCred; 
    smtp.Port = 25; 
    smtp.Send(mm); 
} 
+0

端口25送我低安全連接錯誤 –

+0

@RezaPaidar刪除'smtp.EnableSsl = TRUE;'並再次嘗試 – Mostafiz

+0

給我「服務器不支持安全連接「。 –