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

Php Pear邮件,无法将发件人设置为错误,php,email,gmail,pear,Php,Email,Gmail,Pear,我安装了Pear Mail,在尝试发送邮件时出现以下错误。 在网上搜索,没有任何答案,没有任何线索? 您好,我安装了Pear Mail,在尝试发送邮件时出现以下错误。 在网上搜索,没有任何答案,没有任何线索 unable to set sender to [me@gmail.com] 代码: 这是一个不太可能的选择,但我想你已经建立了自己的gmail帐户。 否则,您将无法模拟me@gmail.com <?php // Include the Mail package

我安装了Pear Mail,在尝试发送邮件时出现以下错误。 在网上搜索,没有任何答案,没有任何线索? 您好,我安装了Pear Mail,在尝试发送邮件时出现以下错误。 在网上搜索,没有任何答案,没有任何线索

unable to set sender to [me@gmail.com]
代码:


这是一个不太可能的选择,但我想你已经建立了自己的gmail帐户。
否则,您将无法模拟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());
   }

?>