我有Windows Vista和我檢查它沒有默認的虛擬smtp在其IIS中。密碼恢復控制無法發送郵件
我用端口25的本地主機發送密碼恢復控制的電子郵件,但它不起作用。
如何發送電子郵件?
我現在工作了。這裏是我的代碼:
PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
e.Cancel = true;
PasswordRecovery1.MailDefinition.BodyFileName = "~/password.txt";
SmtpClient smtp = new SmtpClient();
smtp.EnableSsl = true;
smtp.Send(e.Message);
}
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.gmail.com" port="587" userName="[email protected]" password="xxxxx"/> </smtp>
</mailSettings>
在password.txt文件,我寫了「你可以通過下面的登錄信息返回給該網站password.txt文件,我寫了」你可以通過下面的登錄信息返回到該網站。
<br>Username = <%Username%> </br>
<br>Password = <%password%>" </br>
我們需要更多細節,究竟是什麼問題? –
你會得到什麼例外?你是否檢查過IIS沒有監聽SMTP連接,你是否檢查過什麼_is_ listen?檢查您的SMTP服務器的日誌,看看它是否收到消息並以某種方式失敗(因此與C#應用程序無關)。 – David
地獄的朋友,我做了很多搜索找到答案,並最終得到它。現在它工作正常。我沒有在系統上安裝任何免費的SMTP。相反,我使用smtp.gmail.com作爲服務器來發送郵件。 protected void PasswordRecovery1_SendingMail(object sender,MailMessageEventArgs e) e.Cancel = true; PasswordRecovery1.MailDefinition.BodyFileName =「〜/ password.txt」; SmtpClient smtp = new SmtpClient(); smtp.EnableSsl = true; smtp.Send(e.Message); } – user662417