我写了一个发送邮件的程序,在本地可以使用,在原来的windows 2003服务器上也可以,现在部署的服务器是windows 2008,结果现在邮件发不出了,报以下错误:System.Net.Mail.SmtpFailedRecipientException: Mailbox name not allowed. The server response was: sorry, that domain isn't allowed to be relayed thru this MTA (#5.7.1).请问谁碰到过这个问题,怎么解决,程序如下,我估计应该不是程序的问题,是要在服务器上设置什么吗?我的端口号25也是开放了的。 string strSmtpServer = "";
string strFrom = "";
string strFromPass = "";
try
{
if (strSmtpServer == null || strSmtpServer.Trim() == "")
{
strSmtpServer = "***";
} System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer);
client.UseDefaultCredentials = true;
client.Port = 25;
if (strFrom == null || strFrom.Trim() == "")
{
strFrom = "****";
}
if (strFromPass == null || strFromPass.Trim() == "")
{
strFromPass = "***";
}
client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
client.DeliveryMethod = SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(strFrom, "***", "11111", "111111");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.Priority = MailPriority.High;//邮件优先级
message.IsBodyHtml = true;
client.Send(message);
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
}
string strFrom = "";
string strFromPass = "";
try
{
if (strSmtpServer == null || strSmtpServer.Trim() == "")
{
strSmtpServer = "***";
} System.Net.Mail.SmtpClient client = new SmtpClient(strSmtpServer);
client.UseDefaultCredentials = true;
client.Port = 25;
if (strFrom == null || strFrom.Trim() == "")
{
strFrom = "****";
}
if (strFromPass == null || strFromPass.Trim() == "")
{
strFromPass = "***";
}
client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
client.DeliveryMethod = SmtpDeliveryMethod.Network; System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(strFrom, "***", "11111", "111111");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.Priority = MailPriority.High;//邮件优先级
message.IsBodyHtml = true;
client.Send(message);
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货