当我使用outlook时,我能够发送测试电子邮件到我的gmail地址,但是,当我从控制台应用程序执行它时触发:“服务器的回应是:5.7.1无法中继“编程电子邮件触发“服务器响应是:5.7.1无法中继”
using System.Net.Mail;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MailMessage mail = new MailMessage("[email protected]", "[email protected]");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "xxx.xxx.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
}
}
}
我证实我通过Outlook有正确的客户端主机。我还给我自己发了一封测试邮件(从xx @ mycompany到xx @ mycompany)并且工作正常(尽管它将邮件发送到垃圾邮箱)。为什么它不让我通过这个控制台应用程序发送传出的电子邮件,但我可以通过Outlook中的相同地址。
检查类似的问题:http://stackoverflow.com/questions/3165721/mailbox-unavailable-the-server-response-was-5-7-1-unable-to-relay-for-abcxyz –
是啊我做了,尽管有相同的错误信息,但对我来说,这看起来不是同样的问题。 –
即时通讯发送到Gmail帐户,我不需要本地端口的SMTP服务器? –