Windows平台下使用XAMPP之Sendmail功能設定方法

Window本身沒有”sendmail”的功能,如果想用跟Unix-like中一樣Sendmail的功能,
XAMPP可以使用Fake-sendmail來替代,這必須準備一組SMTP來作為Sendmail發信用。

設定的方法如下:

1.修改 x:\xampp\sendmail\sendmail.ini 檔案,修改以下資料:

smtp_server=smtp.gmail.com
[email protected]
auth_password=abcde

2.修改 x:\xampp\apache\bin\php.ini 檔案,修改以下資料:

[mail function]
; For Win32 only.
;SMTP = localhost
;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 = "E:\xampp\sendmail\sendmail.exe -t"
< ?php
$now = date("Y-m-d h:i:s");
$from_name = '測試寄件者';
$from_email = '[email protected]';
$headers = 'From: $from_name ';
$body = '嗨, \n 這是一封測試信件來自 $from_name < $from_email>.';
$subject = '[$now] 測試信件發送';
$to = '[email protected]';
if (mail($to, $subject, $body, $headers)) {
    echo "success!";
} else {
    echo "fail…";
}
?>

发表评论

你必须 登录 才能发表评论.