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

在xp下发邮件的问题
系统:Xp sp2 iis smtp开通 没有域名 
用JMail 和CDO 发送都出现错误:550 5.7.1 Unable to relay for mm@163.com
邮件地址和其他参数设置都没有问题.
请问高手问题出在那里?




------解决方案--------------------
是用smtp解决的。你最好先在21cn.com申请一个邮箱,我试过,像sina,163等服务器确实不行的。至于Jmail我一直没试成功过。但以下的方案也不能保证每次都发送邮件成功,但大部分可以成功,你可以试一下看看。

private bool senMail(string mailTo, string mailFrom, string subject, string body)
{
MailMessage mail = new MailMessage();
mail.To = mailTo;
mail.From = mailFrom;
mail.Subject = subject;
mail.Body = body;
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "foxqd"); //set your username here 
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "******"); //set your password here 

SmtpMail.SmtpServer = "smtp.21cn.com"; //your real server goes here 
try
{
SmtpMail.Send(mail);
return true;
}
catch (Exception)
{
return false;
}
}
------解决方案--------------------
可以到这里参考一下http://www.ebookit.cn/294.html,是NET2.0的,也许你能使用得上!记得多光临俺的网站,谢谢!