【发布时间】:2013-08-20 21:42:53
【问题描述】:
我有一个带有一些电子邮件的域并与这个域一起使用谷歌应用程序,在这种情况下,我想使用 gmail 的 smtp 毫无问题地向我的客户发送一些电子邮件
这个脚本对我不起作用,我把这个案例
date_default_timezone_set('Europe/Paris');
require_once("class.phpmailer.php");
require_once("class.smtp.php");
$mail = new PHPMailer();
$body = "gdssdh";
//$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "user@gmail.com"; // GMAIL username
$mail->Password = "123456789"; // GMAIL password
$mail->SetFrom('accountemail@mydomain.com', 'PRSPS');
//$mail->AddReplyTo("user2@gmail.com', 'First Last");
$mail->Subject = "Hello it´s a test";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
【问题讨论】:
-
你遇到了什么错误?你在哪里设置收件人?
标签: php gmail phpmailer google-apps