當我使用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服務器? –