現在的Web應用系統,經常需要有透過e-mail發通知的功能。
可在Windows作業系統環境執行的XAMPP套件,其中的Mercury/32 (以下簡稱:Mercury),就具有SMTP Server的功能。透過這個子套件,我們就可以在程式中,使用SMTP來發送e-mail。
只是.......,Mercury的使用,可沒像XAMPP中的Apache或MySQL一樣的簡單,只需輕輕鬆鬆按個 [Start]鈕,就能將功能啟動。
為了搞定Mercury的設定,可真是快把我搞瘋。今天,我的 Lucky Day 總算到來了,所以,借著好運之助,我Google到一篇文章,參考其中的作法,再加上自己的測試與摸索,終於…..,把這個我「孝想」已久的功能給安裝妥當。
整個安裝設定的主要程序如下:
- 啟動Mercury功能
- 設定Core Module組態
- 設定MercuryS SMTP Server組態
- 設定MercuryE SMTP Client組態
- 設定PHP.INI組態
- 重新啟動Mercury與Apache功能
對於各個程序的執行步驟,說明如下:
啟動Mecury功能
1. 自 "XAMPP Control Panel Application” 啟動Mercury。
2. 系統啟動Mercury。
3. 點選[Admin]鈕,啟動[Mercury/32]的管理軟體。
4. Windows出現[Mercury/32]管理介面的畫面。
設定Core Module
1. 自[Configuration]功能表,選擇[Mercury core module]指令。
2. 在[Mercury Core Module Configuration]的對話方塊,預設的[General]活頁籤,完成下列項目設定:
- 在[Internet name for this system]欄位,填 ”localhost”
- 只勾選[Send copies of all errors to the postmaster]設定

3. 在[Local domains]活頁籤,確定有如下標紅框處之localhost設定:

4. 按[確定]鈕,儲存設定值,並關閉[Mercury Core Module Configuration]對話方塊。
設定MercuryS SMTP Server
1. 自[Configuration]功能表,選擇[Mercury core module]指令。

2. 在[Mercury SMTP Server]的對話方塊,預設的[General]活頁籤,完成下列項目設定:
- 在[Announce myself as]欄位,填 “SMTP”
- 在[IP Interface to use]欄位,填 “127.0.0.1” (因為我有其它的考量,所以我在此欄填了一個Private IP)

3. 點選[Connection control]活頁籤,看到如下畫面:

4. 按[Add restriction]鈕,準備設定IP: 127.0.0.1為SMTP Server會提供服務的IP網址。
5. 在[IP Address reang]的[from]及[to]欄位填入 “127.0.0.1” ;確認[Attributes for this entry]的選項,設定為[Allow connections];最後按[OK]鈕,結束此設定動作。

6. 再度回到[Connection control]活頁籤時,可在[Connection control]的清單中,看到IP Address為127.0.0.1的網址,為允許(Allow)的設定項目。

7. 按[確定]鈕,儲存設定值,並關閉[Mercury SMTP Server]對話方塊。
設定MercuryE SMTP Client
1. 自[Configuration]功能表,選擇[MercuryE SMTP Client]指令。
2. 出現[MercuryE End-to-end SMTP Client Configuration]對話方塊。
3. 在[Name servers]欄位,輸入"168.95.1.1"。

4. 按[Save]鈕,儲存設定值,並關閉[MercuryE End-to-end SMTP Client Configuration]對話方塊。
設定PHP.INI
1. 使用您喜愛的文字處理器(Editor) ,打開路徑應在“C:\xampp\php” 的 “PHP.INI”檔案。
2. 加入 “sendmail_from =
postmaster@localhost” 設定。

3. 儲存並關閉這個檔案。
重新啟動Mercury與Apache
1. 切換到[XAMPP Control Panel Application]視窗。

2. 按 Mercury 右邊的[Stop]鈕,結束 Mercury 的功能(等於關閉SMTP Server的功能)。

3. 如法泡製,按 Apache 右邊的[Stop]鈕,結束 Appache 的功能(等於關閉Web Server的功能)。
4. 按 Apache 右邊的[Start]鈕,再次啟動 Apache 的功能(等於重新啟動Web Server的功能)。
5. 按 Mercury 右邊的[Start]鈕,再次啟動 Mercury 的功能(等於重新啟動SMTP Server的功能,執行這個重新啟動的程序,為的是要讓剛才的設定能正常運作)。
