2010-07-17 306 views
0

我曾在IIS中管理SMTP服務器配置以通過asp發送電子郵件作爲中繼部分我添加了我的PC IP傳遞>高級我在智能主機中將我的域名添加爲mail.elarabygroup.com。發送帶有SMTP的電子郵件

我加入這個代碼:

<script runat="server"> 
     protected void SendEmail(object sender, EventArgs e) 
     { 
      SmtpClient smtpClient = new SmtpClient(); 
      MailMessage message = new MailMessage(); 
      try 
      { 
       // Prepare two email addresses 
       MailAddress fromAddress = new MailAddress(
       "[email protected]", "From Kareem Test"); 
       MailAddress toAddress = new MailAddress(
       "[email protected]", "From Kareem Test"); 
       // Prepare the mail message 

       message.From = fromAddress; 
       message.To.Add(toAddress); 
       message.Subject = "Testing!"; 
       message.Body = "This is the body of a sample message"; 
       // Set server details 
       smtpClient.Host = "localhost"; 
       // Uncomment for SMTP servers that require authentication 
       //smtpClient.Credentials = new System.Net.NetworkCredential(
       // "user", "password"); 
       // Send the email 
       smtpClient.Send(message); 
       // Inform the user 
       statusLabel.Text = "Email sent."; 
      } 
      catch (Exception ex) 
      { 
       // Display error message 
       statusLabel.Text = "Coudn't send the message!"; 
      } 
     } 
    </script> 

但出現錯誤:

郵箱無法使用。服務器響應如下:5.7.1無法中繼[email protected]

回答

0

與電子郵件服務器的管理員通話。您顯然不允許默認中繼,因此您可能需要提供登錄名/密碼組合到服務器(請參閱您的代碼段中的NetworkCredentials)。

你表示你的接力可能是mail.elarabygroup.com ---是有意識的「e」它與您在示例中使用的域不同?這可能是你不允許接力的原因。

+0

「e」我錯過了它,但它沒有這個原因。也[email protected]我通過outlook使用它來發送和reciev電子郵件。 – Myworld 2010-07-18 09:00:01

+0

我fogot告訴我,我在VM ware – Myworld 2010-07-18 09:07:38

+0

[不](http://meta.stackexchange.com/questions/46035/should-i-remove-tags-that-dont-contribute-to-categorizing-問題/ 46037#46037)[標籤](http://meta.stackexchange.com/questions/43879/anti-tags-valid-use-or-not)[與編程無關。](http:/ /meta.stackexchange.com/questions/10216/can-we-disallow-the-use-of-belongs-on-xxxxxxx-and-not-programming-related-tag/10222#10222)(另外,名稱爲3字母,所以[評論回覆](http://meta.stackexchange.com/questions/43019/how-do-comment-replies-work)工作,將是有益的。:) – 2010-07-18 09:33:26