在网络外发送邮件

时间:2017-10-13 10:54:51

标签: c# email smtp

如何在网络外发送邮件。目前我正在使用以下代码:

MailMessage objMailMsg = new MailMessage();
MailAddress FromAddress = new MailAddress("from@testmail.net");
MailAddress ToAddress = new MailAddress("to@testmail.net");
objMailMsg.From = FromAddress;
objMailMsg.To.Add(ToAddress);
objMailMsg.Subject = "Test";
objMailMsg.Body = "This is a test mail";
objMailMsg.IsBodyHtml = true;

int port = 25;
string IPaddr = "10.1.0.125";

SmtpClient smtpClient = new SmtpClient();
smtpClient.Port = port;
smtpClient.Host = IPaddr;
smtpClient.Send(objMailMsg);

运行时,我收到异常:邮箱不可用。服务器响应为:5.7.1无法中继

我应该在哪里改变。在代码中还是与SMTP相关?

0 个答案:

没有答案