Mail()函数对我不起作用

时间:2016-12-14 16:45:23

标签: php email

我知道这个问题在这个网站上有很多答案,但没有答案对我有用。所以请帮助我...

我试图在php邮件功能中发送邮件

这是index.php

<?php
$to = "test@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: my gmail ID@gmail.com";
try{

  if(mail($to, $subject, $txt, $headers))
    echo "email has been sent successfully";
  else
    echo "Unknown Error";
}catch(Exception $s){
  echo $s->getMessage();
}
 ?>

这是php.ini

[mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my sender ID@gmail.com  
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"   
mail.add_x_header=On    
extension=php_openssl.dll

这是sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=my sender ID@gmail.com
auth_password= my ID password
force_sender=my sender ID@gmail.com

注意:XAMPP v 3.2.2

注意:PHP v 7.0.13

0 个答案:

没有答案