E​x​c​h​a​n​g​e​邮​箱​搭​建

出现的问题:

System.Runtime.InteropServices.COMException(0x8004020F): The server rejected one or more recipient addresses.

 

这个问题
需要设置可以通过指定邮件服务器进行relay的ip地址

smtp->properties->access->relay
add the ip address

 public bool Send(string to, string from, string subject, string message)
         {
              try
              {
                   MailMessage em = new MailMessage();
                   em.To = to;
                   em.From = from;
                   em.Subject = subject;
                   em.Body = message;
 
                   //Found out how to send authenticated email via System.Web.Mail at http://SystemWebMail.com (fact 3.8)
                   if(this.UserName != null && this.Password != null)
                   {
                       em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");   //basic authentication
                       em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here
                       em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here
                   }
 
                   SmtpMail.SmtpServer = this.SmtpServer;
                   SmtpMail.Send(em);
                   return true;
              }
              catch
              {
                   return false;
              }
          }
 
     }
}   

 

E​x​c​h​a​n​g​e​邮​箱​搭​建:

http://wenku.baidu.com/link?url=PBI6WseFEs8dQCjEAcmzmMZ6VdXmQ44RcvVl9BR8b5rtzsVBbJEX1AcV8VwwSH49rcy9KB7_I5Xgia5EmkqlbUcSbO_qLIzmRJwACKmmlPO

posted @ 2014-05-21 09:49  kanek  阅读(248)  评论(0编辑  收藏  举报