【发布时间】:2011-07-21 05:10:27
【问题描述】:
我正在尝试在一个项目中使用 PHP Pear Factory 通过 GMail 发送电子邮件。它已经成功了,但是有些东西不能 100% 正常工作。
我不知道为什么如果我设置$headers['From'] = 'from@domain.com',当我收到电子邮件时,发件人是用户名@gmail.com。
在代码下方找到:
$recipients = 'to@domain.com';
$headers['From'] = 'from@domain.com';
$headers['To'] = 'to@domain.com';
$headers['Subject'] = 'Test message';
$body = 'Test message';
$params["host"] = 'ssl://smtp.gmail.com';
$params["port"] = 465;
$params["auth"] = true;
$params["username"] = 'username@gmail.com';
$params["password"] = 'password';
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);
$send = $mail_object->send($recipients, $headers, $body);
if(PEAR::isError($send)) { print($send->getMessage()); }
【问题讨论】: