【发布时间】:2011-11-11 23:02:18
【问题描述】:
可能重复:
PHP mail using Gmail
代码:
<?
//change this to your email.
$to = "bhavesh412@gmail.com";
$from = "bhavesh412@gmail.com";
$subject = "Hello! This is HTML email";
//begin of HTML message
$message = <<<EOF
<html>
<body bgcolor="#DCEEFC">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br>
<font color="red">Thanks Mohammed!</font> <br>
<a href="http://www.maaking.com/">* maaking.com</a>
</center>
<br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email@maaking.cXom[/email]";
// now lets send the email.
ini_set("SMTP","smtp.gmail.com");
ini_set("smtp_port","465");
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
我遇到以下错误:
警告:mail() [function.mail]:无法在“smtp.gmail.com”端口 465 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 ini_set() C:\xampp\htdocs\testMail.php 第 31 行
致命错误:C:\xampp\htdocs\testMail.php 第 33 行的最大执行时间超过 30 秒
【问题讨论】:
-
据我所知,Google 的 SMTP 服务器需要身份验证以及使用加密 (SSL/TLS) 连接。您不能只指向带有 2 或 3 个标头的 smtp.gmail.com 并发送电子邮件。
-
谢谢你们,我刚接触 php 可以说只是第一天,所以尝试 diff 的东西 thnaks 为你的指导
标签: php