用php发送邮件

时间:2013-12-11 22:04:03

标签: php email sendmail.exe

我的php有问题:我想在php.I中使用XAMPP发送一个简单的邮件 我的配置是: php.ini中: 只有sendmail和mail.add_x_header没有评论

; For Win32 only.
; http://php.net/smtp
;SMTP = smtp.gmail.com
; http://php.net/smtp-port
;smtp_port = 587
sendmail_path = "C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header = Off

sendmail.ini:

smtp_server=smtp.gmail.com
;smtp port (normally 25)
smtp_port=587
smtp_ssl=true
auth_username=myemail@gmail.com
auth_password=mypassword

和index.php

<?php
$subject="Hi There!!";
$to="nick@yahoo.com";
$body="This is my demo email sent using PHP on XAMPP";
if (mail($to,$subject,$body))
 echo "Mail sent successfully!";
   else
   echo "Mail not sent!";
  ?>

它运行没有错误,但邮件没有来......我的错误在哪里?pliz帮助我

1 个答案:

答案 0 :(得分:1)

您的sendmail_path设置中有一个额外的引号。尝试从以下位置更改php.ini文件:

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

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

您是在个人ISP还是在工作中这样做?您的端口可能被阻止。此外,雅虎也可能会过滤您的电子邮件。可以尝试添加标题。