2017-04-25 42 views
0

第三方連接到郵件服務器,如果我通過託管服務提供商諸如A2 Hosting第三方託管一個asp.net應用程序的核心是可以利用這個來發送郵件瓦特/郵件套件?我已經嘗試了很多不同的東西和client.Connect只是掛起,並最終拋出異常。 Ex爲空。使用MailKit從託管服務提供商

這裏是我的代碼:

  using (var client = new SmtpClient()) 
      { 
       // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS) 
       client.ServerCertificateValidationCallback = (s, c, h, e) => true; 

       client.Connect("mail.mydomain.com", 25, false); 

       // Note: since we don't have an OAuth2 token, disable 
       // the XOAUTH2 authentication mechanism. 
       client.AuthenticationMechanisms.Remove("XOAUTH2"); 

       // Note: only needed if the SMTP server requires authentication 
       client.Authenticate("[email protected]", "PASSWORD"); 

       client.Send(message); 
       client.Disconnect(true); 
      } 

回答

0

事實證明,我的ISP(康卡斯特)阻止端口25。我的託管公司告訴我,他們打開端口2525這個原因。我將其更改爲2525,並且工作正常。如果你遇到類似的問題,看看他們有可能開什麼額外的端口了,請聯繫您的託管公司。

相關問題