我创建从服务器的IP,而不是SMTP发送电子邮件地址的电子邮件客户端,我写的代码:SMTP:错误中继
SmtpClient server = new SmtpClient("50.23.128.66");
MailMessage msg = new MailMessage("[email protected]", "[email protected]", "subject", "body");
server.Send(msg);
但是当我运行它,我得到这个错误:
Unhandled Exception: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Relaying Denied. at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressColl ection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
*顺便说一句,我使用的Windows Server 2008 * 和我配置的SMTP服务器localhost和端口25,但我不`吨知道的是,依赖错误。
当您通过“bar.com”SMTP服务器发送“someone @ foo.com”电子邮件时,您使用'bar.com'服务器作为邮件中继。如果bar.com服务器未配置为中继邮件,它将拒绝不属于其自己域或其用户的SMTP尝试。换句话说,这不是一个编程错误,而是一个服务器错误,你应该检查服务器配置。也许更适合于serverfault.com。 – 2012-01-16 18:59:43