爲了在本地環境測試註冊郵件功能,開啓了XAMPP的Mercury,郵件服務器,但奇怪的是,使用Sent mail message,卻不能發送成功。上網找了很久,總結出設置方法。
- 啓動Apache和MySQL服務;
- 點擊 Mercury 頂部菜單的“Configuration / MercuryS SMTP Server” ,在彈出的對話框上點擊“Connection control”標籤頁,去掉“Do not permit SMTP relaying of non-local mail”這一項的勾選,然後點擊“確定”;
- 點擊 Mercury 頂部菜單的“Configuration / Protocol modules” ,在彈出的對話框裏取消“MercuryB HTTP web server”、“Mercury IMAP4rev1 server”的選擇,然後在“MercuryC SMTP relaying client”前勾選,同時也是取消了“MercuryE SMTP end-to-end delivery client”勾選,點“確定”,重啓Mercury;
- 點擊 Mercury 頂部菜單的“Configuration / Mercury core module” ,在彈出的對話框裏進入“General”標籤頁,在“internet name for this system”裏填入“localhost”;在下面,除了“Send copies of all errors to postmaster”外,全部取消勾選;進入“Local domains”標籤頁,確認有“localhost (local host or server) localhost (internet name)”值對,如果沒有,手動添加上,點“確定”;
- 點擊 Mercury 頂部菜單的“Configuration / MercuryS SMTP Server” ,在彈出的對話框裏進入“General”標籤頁,在“Announce myself as”裏填入你喜歡的名字,比如“super smtp”;在“IP interface to use”裏填入“127.0.0.1”;在“Connection Control”標籤頁裏,取消全部勾選,點“確定”;
- 點擊 Mercury 頂部菜單的“Configuration / MercuryC SMTP Client” ,這裏的設置很重要,基本上可以說成敗在此一舉,如果要對外發郵件,還得有另外可用的SMTP服務器,在“Smart host name”裏填入,比如“smtp.gmail.com”;“Connection port/type”是“25”/SSL encryption via STARTTLS command(gmail是得這麼設置);在“Login username”和“Password”裏填入用戶名和密碼;
- 點擊 Mercury 頂部菜單的“Configuration / Manage local users” ,在這裏添加或設置用戶名和密碼,外部程序要用到這個才能使用本郵件服務;
- 在“xampp/php/php.ini”中查找[mail function]確定以下的鍵值對設置:
- “SMTP = localhost”
- “smtp_port = 25″
- “sendmail_from = postmaster@localhost”
好了,現在應該可以試試“Sent mail message”了。