2014年1月6日 星期一

[IIS SMTP Server設定] asp.net SMTP寄信的功能

Reference:http://myjcheng.blogspot.tw/2009/05/aspnet-smtp.html

asp.net SMTP寄信的功能

using System.Net.Mail;

MailMessage msg = new MailMessage();
msg.From = new MailAddress("id@gmail.com", "Me");
msg.To.Add(new MailAddress("id@gmail.com", "User"));
msg.Subject = "主題" ;
msg.Body = "信件內文" ;
msg.IsBodyHtml = true ;
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("127.0.0.1") ;
smtp.Send(msg);
-------------------------------------------------------------------------------------------------
IMM Server 之 Email 必須透過Local SMTP Service來傳遞,因此會建議安裝 IIS SMTP Service 以支援該功能。
但預設的 IIS SMTP 設定是不允許幫你轉發信件的,必須做下述的設定:

1. 開啟 [IIS 管理員] 之 [預設 SMTP 虛擬伺服器] 設定


2. 在 [存取] 的畫面中,針對 [轉換限制] 進行設定,將該台機器的 IP 加入可允許的清單中,例如 "127.0.0.1" 及 "192.168.1.195"



3. 在 [傳遞] -> [進階...] 的畫面中,設定你的網域及智慧主機。所謂智慧主機代表此IIS SMTP Service會將信送至該智慧主機,再由該智慧主機將信件送至接收者。



3. 使用 DocuPack 中的 SMTP_Tester 來進行測試,若可發信成功,則在 Send Result 畫面中會顯示成功,你也可用一般看信軟體去確認該用戶是否有收到該測試信件。


------------------------------------------------------------------------------------------------------

參考:
http://forum.docutek.com.tw/index.php?topic=125.0
http://blog.blueshop.com.tw/ajun/archive/2006/07/24/34592.aspx

沒有留言:

張貼留言