PHPMailer不能替代发件人?

时间:2017-03-13 09:51:35

标签: php email phpmailer

尝试通过PHPMailer从网站发送邮件:

require_once 'vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    $mail->CharSet = "UTF-8";
    $mail->isSMTP();    // Set mailer to use SMTP
    $mail->Host = 'smtp.yandex.ru'; // Specify main SMTP server
    $mail->SMTPAuth = true;   // Enable SMTP authentication
    $mail->Username = 'mylogin'; // SMTP username
    $mail->Password = 'password';   // SMTP password
    $mail->SMTPSecure = 'ssl';  // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;    // TCP port to connect to

    $mail->setFrom('sender_from_site@gmail.com', 'User on site');
    $mail->addAddress('recipient@yandex.ru', 'Mail reader'); // Add a recipient
    $mail->isHTML(true);          // Set email format to HTML

    $mail->Subject = 'Here is the subject';
    $mail->Body = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    imail->send();
} catch (phpmailerException $e) {
    echo $e->errorMessage();
} catch (Exception $e) {
    echo $e->getMessage();
}

此代码使用以下信息生成phpmailerException异常:

  

以下发件人地址失败:sender_from_site@gmail.com:MAIL   FROM命令失败,发件人地址被拒绝:不属于auth用户。   ,553,5.7.1SMTP服务器错误:MAIL FROM命令失败详细信息:发件人   地址被拒绝:不属于auth用户。 SMTP代码:553附加   SMTP信息:5.7.1

好的,但这不是错误 - 我的想法是直接从发件人那里收到电子邮件。

如何替代真正的发件人?

0 个答案:

没有答案