日期:2014-05-18  浏览次数:20543 次

在线求解Asp.net发送Email问题!急!急!
做个小网站要发送Email.我在本地是没有问题的.但是上传到服务器上(Window   2003   Server操作系统).出现 "与服务器连接传输失败. ";防火墙什么都关了。我开始是用System.Web.Mail.MailMessage做的.后来改用TcpClient做在本地也是没有问题的.但是到服务器
  tcp   =   new   TcpClient();tcp.Connect( "smtp.163.com ",25);
bool   isConection=tcp.Connected;直接连接不上远程服务器.
我感觉不是程序的问题.而是服务器的配置.我用的不是03系统自带的本机Smtp邮件服务器.而是连接163的服务器.我感觉不是程序的问题.而是03的安全配置问题.请各位03有什么配置要注意的地方.
public   class   SendSmtpMail
{
        public   string   From;//发件人
        public   string   To;//收件人
        public   string   Subject;//标题
        public   string   Body;//内容
        public   string   PassWord;//发件人密码
        public   string   SmtpServer;//服务器
        internal   void   GoToSendMail()
        {
              System.Web.Mail.MailMessage   mailMessage   =   new   System.Web.Mail.MailMessage();
              mailMessage.BodyFormat   =   System.Web.Mail.MailFormat.Html;
                mailMessage.From   =   this.From;
                mailMessage.To   =   this.To;
              mailMessage.BodyEncoding   =   System.Text.Encoding.GetEncoding(936);
                mailMessage.Subject   =   this.Subject;
                mailMessage.Body   =   this.Body;
              mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/sendusing "]   =   2;
          mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/sendemailaddress "]   =   this.From;//发送地址;
            mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/smtpaccountname "]   =   this.To;
              mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/sendusername "]   =   this.From;//验证账号:发送者邮箱账号  
              mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/sendpassword "]   =   this.PassWord;   //验证密码:发送者邮箱密码  
              mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate "]   =   1;   //   验证级别0,1,2  
              mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/languagecode "]   =   0x0804;//语言代码  
        mailMessage.Fields[ "http://schemas.microsoft.com/cdo/configuration/smtpserver "]   =   this.SmtpServer;   //SMTP   Server  
              System.Web.Mail.SmtpMail.SmtpServer   =   this.SmtpServer;
                System.Web.Mail.SmtpMail.Send(mailMessage);
        }
}这是我的一个写的一个简单类.我监视所有都是正确的.没有办法老板都说是我的程序写的问题.他们什么也不懂.就让我把搞.怎么解释也不行.

------解