2017-04-25 43 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,并且工作正常。如果你遇到类似的问题,看看他们有可能开什么额外的端口了,请联系您的托管公司。

相关问题