同样的一段代码,有的SMTP服务器可以发邮件而有的就不行。代码如下:
MailMessage objMail = new MailMessage();
objMail.From = showName + "<" + fromMail + ">";
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = userName;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/languagecode"] = 0x0804;
objMail.To = toMail;
objMail.Subject = title;
objMail.Body = content;
objMail.BodyFormat = format;
objMail.Priority = MailPriority.Normal;//优先级
objMail.BodyEncoding = Encoding.UTF8;SmtpMail.SmtpServer = smtpserver;
SmtpMail.Send(objMail);对于163.com,tom.com,21cn.net这样的著名邮箱,发送没有问题;但如果用公司租用的企业邮箱(中国万网的,邮箱后缀使用公司自己的域名)就不行。错误提示:
邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc6a。服务器响应为 451 Requested action aborted: local error in processing怀疑是不是企业邮箱所在的SMTP服务器做了什么限制,可是用outlook发送又没问题,配置也与163、21cn的没什么两样。谁能告诉俺?
MailMessage objMail = new MailMessage();
objMail.From = showName + "<" + fromMail + ">";
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = userName;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/languagecode"] = 0x0804;
objMail.To = toMail;
objMail.Subject = title;
objMail.Body = content;
objMail.BodyFormat = format;
objMail.Priority = MailPriority.Normal;//优先级
objMail.BodyEncoding = Encoding.UTF8;SmtpMail.SmtpServer = smtpserver;
SmtpMail.Send(objMail);对于163.com,tom.com,21cn.net这样的著名邮箱,发送没有问题;但如果用公司租用的企业邮箱(中国万网的,邮箱后缀使用公司自己的域名)就不行。错误提示:
邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc6a。服务器响应为 451 Requested action aborted: local error in processing怀疑是不是企业邮箱所在的SMTP服务器做了什么限制,可是用outlook发送又没问题,配置也与163、21cn的没什么两样。谁能告诉俺?
另外如果邮件发送过于频繁的话,有些smtp服务器会视为邮件攻击.因此拒绝你的服务。
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = userName;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = password;
objMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
已经写上帐号、密码,指明服务器需要认证了。
先TELNET服务器一下。看对方是否允许你连接,并且连接是否成功
220 mxvip25.hichina.com ESMTP server (quarkmail server - version 1.2.1) ready at
Wed, 31 May 2006 18:06:29 +0800
220 mxvip25.hichina.com ESMTP server (quarkmail server - version 1.2.1) ready at
Wed, 31 May 2006 18:25:29 +0800
EHLO LOCALHOST
250-mxvip25.hichina.com Hello LOCALHOST
250-SIZE 20971520
250-8BITMIME
250-PIPELINING
250-AUTH=LOGIN
250-AUTH LOGIN
250 HELP
邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc15。服务器响应为 not available