可能的重复:
使用 Gmail 的 PHP 邮件 https://stackoverflow.com/questions/36079/php-mail-using-gmail
code :
<?
//change this to your email.
$to = "[email protected] /cdn-cgi/l/email-protection";
$from = "[email protected] /cdn-cgi/l/email-protection";
$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][email protected] /cdn-cgi/l/email-protection[/email]";
//$headers .= "Bcc: [email][email protected] /cdn-cgi/l/email-protection[/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”设置或使用 C:\ 中的 ini_set() xampp\htdocs\testMail.php 第 31 行
致命错误:C:\xampp\htdocs\testMail.php 第 33 行超出了最大执行时间 30 秒
Gmail 服务器使用 TLS 和登录/密码身份验证,您不能将它们与 PHP 一起使用mail() http://php.net/mail功能。
尝试使用邮件库,例如斯威夫特梅勒 http://swiftmailer.org/。下面是一个可以与 Gmail 配合使用的示例:http://swiftmailer.org/wikidocs/v3/connections/smtp http://swiftmailer.org/wikidocs/v3/connections/smtp
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)