dongzheng8463 2013-06-08 15:57
浏览 24

PHPMailer $ mail->来自不使用gmail的标头

I'm using the following code to send a mail after a form submission with the PHP mailer class The mail sends and is received successfully. The only thing that isn't wokring is the following:

$mail->From = $email;

$email is the email that a user will enter on the form (it is set with a $_POST variable). I would like the email to appear that it's from the user who filled out the form, so I can hit reply and have it go to their email address.

However, the "from" email address is being set as $mail->Username, i.e. the username from the gmail account that the PHPMailer script is sending from.

enter image description here

What am I doing wrong here, and how do I get the From email header to work?

Also, I am using Gmail to receive the mail-- maybe there's a gmail security setting that won't allow the "From" email to be "faked"???


$email = $_POST['email'];
$name = $_POST['moveName'];

$mail = new PHPMailer();

$mail->Host = 'ssl://';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = 'password';

$mail->From = $email;
$mail->FromName = $name;
$mail->AddReplyTo($email, $name);


$mail->Subject = 'Quote Request';
$mail->Body    = 'hey';

  • 写回答

1条回答 默认 最新

  • dtg25862 2013-06-08 17:32

    With gmail you have to configure an email address as allowed "$mail->from" first. This FAQ entry explains how to do it:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作