php邮件功能

时间:2010-11-13 06:47:58

标签: php

我的网站上有一个表单。当用户输入数据时,它应该达到我的Gmail代码。我尝试了很多东西,但它没有用。

http://pastebin.com/xABBduyB

这是php.ini中的设置

SMTP = smtp.gmail.com
sendmail_from = myname@gmail.com
SMTP_PORT = 465

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:1)

PHP mail功能仅适用于标准SMTP,但要访问Gmail服务器,您需要使用SMTP over SSL。您可以找到如何执行此操作的示例over here

答案 1 :(得分:0)

最简单的解决方案是使用phpmailer

这是使用Google搜索的示例代码:

$mail->Mailer = "smtp";  
$mail->Host = "ssl://smtp.gmail.com";  
$mail->Port = 465;  
$mail->SMTPAuth = true; // turn on SMTP authentication  
$mail->Username = "username@gmail.com"; // SMTP username  
$mail->Password = "password"; // SMTP password  
相关问题