Everything’s done. Lets test if the mail() function is working now:if ( mail ( [email protected]', 'Test mail from localhost', 'Working Fine.' ) );echo 'Mail sent';elseecho 'Error. Please check error log.';
Replace the [email protected] with your own username, save it into a php file along with php delimeters in your virtual host root folder and execute it through the browser. You should receive a mail.
跟上述步驟大同小異。
msmtp在ubuntu下apt-get install msmtp就可以安裝, 安裝完後, msmtp --ver 查看:
......
?
System configuration file name: /etc/msmtprc
User configuration file name: /root/.msmtprc
顯然要保證有/etc/msmtprc檔案並要設定好它的配置內容。我的/etc/msmtprc內容如下:# Set default values for all following accounts.
defaults
logfile /usr/local/msmtp/msmtp.log
# The SMTP server of the provider.
account test
# SMTP郵件伺服器地址
host smtp.ym.163.com
# 發送的郵件Email
from [email protected]
auth login
# 郵件伺服器登入帳號
user [email protected]
# 郵件伺服器登陸密碼
password 12345678
# Set a default account
account default : test
不過,我開啟上面的測試php時,開始時出來Error. Please check error log.
發送郵件不成功,查看apache的error_log, 找到錯誤資訊:
msmtp: /etc/msmtprc: must be owned by you
原來是/etc/msmtprc的許可權是777的話也不行,需要限制。 ps aux|grep httpd查看apache的進程的使用者名稱是www,
然後:
chown www.www /etc/msmtprc
chmod 600 /etc/msmtprc # 一定要600而不是777 !
搞定!然後在mantis裡配置?$g_phpMailer_method ? ? ? ? ? ? = PHPMAILER_METHOD_MAIL這樣比配置 PHPMAILER_METHOD_SMTP 發郵件要快得多,都可立即收到郵件!
?