梨邮件,无法将发件人设置为错误

时间:2013-02-16 07:22:21

标签: php email gmail pear

我安装了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());
   }

?>

1 个答案:

答案 0 :(得分:0)

这是一个很长的镜头,但我想你已经设置了自己的Gmail帐户。 否则你将无法模仿me@gmail.com