[PHP]針對外伺服器mail函數的php.ini配置

來源:互聯網
上載者:User

標籤:c   code   a   http   com   cti   

php mail()函數在windows不能用,需要安裝sendmail

1.從http://glob.com.au/sendmail/下載sendmail.zip
2.解壓到C:下,例如C:\php\sendmail,最好短路徑,長路徑名有可能產生問題。
3.修改php.ini如下
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
4.根據你自己的配置環境修改sendmail.ini。
第一次最好啟用debug.log_file,error_logfile,以查看sendmail是否生效。
5.重啟apache

用sendmail結合其它的smtp伺服器,如smtp.163.com來實現發郵件。現在大部分郵箱都要求smtp驗證,所以要在sendmail.ini中加入使用者名稱和密碼。
php.ini配置 (以用163郵箱為例)

代碼如下:[mail function]
; For Win32 only.
SMTP = smtp.163.com
smtp_port = 25
; For Win32 ……

用sendmail結合其它的smtp伺服器,如smtp.163.com來實現發郵件。現在大部分郵箱都要求smtp驗證,所以要在sendmail.ini中加入使用者名稱和密碼。
php.ini配置 (以用163郵箱為例)

代碼如下:[mail function]
; For Win32 only.
SMTP = smtp.163.com
smtp_port = 25
; For Win32 only.
sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
sendmail_path = “D:\xampp\sendmail\sendmail.exe -t”

就配置三項,smtp、smtp_port和sendmail_path
sendmail.ini配置

代碼如下:[sendmail]
; you must change mail.mydomain.com to your smtp server
smtp_server=smtp.163.com
smtp_port=25
auth_username=yourusername
auth_password=yourpassword
[email protected]

sendmail網上有下的,如果你是用xampp,那裡面直接就帶了。
同時在虛擬機器主機的conf裡加上這樣一句

代碼如下:php_admin_value sendmail_path ‘D:\xampp\sendmail\sendmail.exe -t [email protected]’

此郵件地址為使用者的郵件地址,隨便添。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.