當前位置:編程學習大全網 - 行動軟體 - 如何在Windows系統中安裝sendmail使用PHP mail函數

如何在Windows系統中安裝sendmail使用PHP mail函數

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

1.下載sendmail.zip

2.解壓到C:下,例如C:\PHP\sendmail,最好短路徑,長路徑名有可能產生問題。

3.修改php.ini如下

sendmail_path = "C:\PHP\sendmail\sendmail.exe -t"

4.根據妳自己的配置環境修改sendmail.ini。

第壹次最好啟用debug.log_file,error_logfile,以查看sendmail是否生效。

5.重啟apache

用sendmail結合其它的smtp服務器,如smtp.gmail.com來實現發郵件。現在大部分郵箱都要求smtp驗證,所以要在sendmail.ini中加入用戶名和密碼。

php.ini配置 (以用gmail郵箱為例)

[mail function]

; For Win32 only.

SMTP = smtp.gmail.com

smtp_port = 25

; For Win32 only.

sendmail_from = zmacro@gmail.com

; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).

sendmail_path = “C:\PHP\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.gmail.com

smtp_port=25

auth_username=yourusername

auth_password=yourpassword

force_sender=zmacro@gmail.com

; default_domain=mydomain.com

sendmail網上有下的,如果妳是用xampp,那裏面直接就帶了。

同時在虛擬主機的’</directory>

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

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

測試文件mail_test.php

<?

if(mail("yourname@sina.com","測試","測試郵件"))

{

echo "發送成功!!";

}

else{

echo "發送失敗!!";

}

>

  • 上一篇:仙劍奇俠傳3(37集版)分集劇情介紹
  • 下一篇:震驚!新西蘭海灘現巨型深海生物屍體,觸手巨大,這是什麽生物呢?
  • copyright 2024編程學習大全網