我安装了 Pear Mail,并在尝试发送邮件时收到以下错误。网上搜了下,没有答案,不知道是怎么回事?嗨,我安装了 Pear Mail,在尝试发送邮件时收到以下错误。网上搜了下,没有答案,不知道是怎么回事?
unable to set sender to [me@gmail.com]
代码:
<?php
// Include the Mail package
require "Mail.php";
// Identify the sender, recipient, mail subject, and body
$sender = "me@gmail.com";
$recipient = "jason@example.com";
$subject = "Thank you for your email!";
$body = "I'll get back to you as soon as I can!";
// Identify the mail server, username, password, and port
$server = "ssl://smtp.gmail.com";
$username = "me@gmail.com";
$password = "supersecret";
$port = "465";
// Set up the mail headers
$headers = array(
"From" => $sender,
"To" => $recipient,
"Subject" => $subject
);
// Configure the mailer mechanism
$smtp = Mail::factory("smtp",
array(
"host" => $server,
"username" => $username,
"password" => $password,
"auth" => true,
"port" => 465
)
);
// Send the message
$mail = $smtp->send($recipient, $headers, $body);
if (PEAR::isError($mail)) {
echo ($mail->getMessage());
}
?>