以下是使用PHP郵件功能PHP郵件()不能在Windows工作(IIS)
$to = "[email protected]";
$subject = "This is the subject line
$message = "This is the message"
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$result = mail($to , $subject , $message, $headers)
下面我的源是我的PHP配置,這是在Windows上運行IIS
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected]
通過你的配置你應該有一個郵件服務或交換在同一個IIS環境上運行。你能證實這是真的嗎?如果沒有,那麼你需要指定一個郵件服務器,否則你應該調試mail()函數來查看它返回的內容:) –
我猜想StackOverflow直接在你的問題中執行的語法突出顯示是一個很好的起點。 – MonkeyZeus
@MonkeyZues確實有一個公平的點,你錯過了一個「;和; –