邮件不通过表单发送

时间:2012-03-29 18:49:16

标签: php email sendmail.exe

这是应发送的邮件(我的PHP中的代码):

$message = 
"Hello \n
Thank you for registering with us. Here are your login details...\n

User ID: $user_name
Email: $usr_email \n 
Passwd: $data[pwd] \n

";

mail($usr_email, "Login Details", $message,
"From: \"Member Registration\" <xxxx@gmail.com>\r\n" .
"X-Mailer: PHP/" . phpversion());

header("Location: thankyou.php");  
exit();

这是我的php.ini详细信息:

; 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 = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
;the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the
;filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and 
;headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"

和我的sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=xxxx@gmail.com
auth_password=xxxxxxx
force_sender=xxxx@gmail.com

我是一个完全的初学者,所以这可能是完全错误的。 当我提交邮件功能所在的表单时,thankyou.php页面显示为指定的

2 个答案:

答案 0 :(得分:0)

检查邮件日志,查看sendmail是否在传递邮件时遇到问题。您的应用通常可以正确地将其发送到sendmail,但sendmail无法将其发送出去。

答案 1 :(得分:0)

我在你的php.ini中注意到了这一点:

仅适用于Unix。您也可以提供参数(默认值:“sendmail -t -i”)。 ; http://php.net/sendmail-path sendmail_path =“\”C:\ xampp \ sendmail \ sendmail.exe \“ - t”

我看了一眼:

http://digiex.net/guides-reviews/guides-tutorials/application-guides/544-configuring-php-under-windows-use-gmail-external-smtp-server-ssl.html

并注意到sendmail路径是这样定义的:

sendmail_path =“C:\ inetpub \ sendmail \ sendmail.exe -t”

AFAIK你真的不需要那些你正在使用的额外引号和斜线。我会尝试上面的格式,并检查您的sendmail日志,看看它是否以某种方式出错。