我得到」遠程名稱無法解析:'smtp.live.com'「異常不斷從過去2小時試圖發送簡單的郵件。 這裏是我的代碼:發送郵件失敗:{「遠程名稱無法解析:'smtp.live.com'}}
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", "Some Name");
mailMessage.To.Add(new MailAddress("[email protected]"));
mailMessage.IsBodyHtml = true;
mailMessage.Body = "<b>This is a check email</b>";
mailMessage.Subject = "Test subject";
SmtpClient smtpClient = new SmtpClient();
smtpClient.Port = 587; //also tried 25 and 465
smtpClient.Host = "smtp.live.com"; //also tried smtp-mail.outlook.com
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false; //also tried removing the credentials and setting this to true
smtpClient.Credentials = new NetworkCredential("[email protected]", "its password");
smtpClient.Send(mailMessage);
Console.WriteLine("Success");
只是出於好奇,我曾嘗試加入smtp.gmail.com到主機並輸入我的Gmail憑證爲好,但也不能工作。這裏的痕跡:
System.Net.Mail.SmtpException was caught
Message=Failure sending mail.
Source=System
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ConsoleApplication1.Program.Main(String[] args) in C:\Users\italha\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 95
InnerException: System.Net.WebException
Message=The remote name could not be resolved: 'smtp.live.com'
Source=System
StackTrace:
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException:
我的Internet連接使用代理地址和端口8080,是什麼問題?請爲我的具體問題提供解決方案,我已經嘗試了所有可用的互聯網通用解決方案。
您是否也使用smtp代理? –
您的郵件憑據是否有效? –
好吧,它甚至沒有嘗試建立連接,但它沒有解決IP - 所以顯然它花了太長的時間來解決..如果你有一個http代理,你可能/幾乎肯定會遇到防火牆問題,機會端口是不是打開你的機器直接通話 – BugFinder