drelgkxl93433 2012-06-24 15:54
浏览 60
已采纳

本机php邮件功能似乎不适用于Gmail

I am trying to use the native PHP function to send a simple test email through gmail SMTP, but it's not working. Going through various forums including Stack Overflow and the only solutions I see are the ones that recommend third-party email libraries/frameworks/api's. Does this mean that PHP's mail() does not work with Gmail, and if so, why?

The following is the code:

<?php
$to ="mail2@yahoo.com";
$sbj ="test mail";
$msg ="testing! testing!! testing!!!";

ini_set("SMTP", "ssl://smtp.gmail.com");
ini_set("smtp_port", 465);
ini_set("sendmail_from", "mail1@gmail.com");

$header ="From: " .ini_get("sendmail_from");

mail($to, $sbj, $msg, $header);

?>

And the error message I got:

Warning: mail(): Failed to connect to mailserver at "ssl://smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\test\web1\test1.php on line 12

  • 写回答

3条回答 默认 最新

  • douxiajia6104 2012-06-24 16:07
    关注

    Does this mean that PHP's mail() does not work with Gmail, and if so, why?

    Gmail servers require user to authenticate before sending any message, mail() does not provide any authentication method

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?