'To' address being added twice while using PHPmailer

懵懂的女人 提交于 2019-12-06 04:12:37
Viacheslav Bakshaev

I had the same problem, for me solution was to change

$mailer->isSMTP();

to

$mailer->Mailer   = 'smtp'; 

So, try to use $mailer->Mailer.

May be there is a page refresh and hence multiple execution - Make sure the mail method is called only once by the browser for each reciever. To make sure, you could set a session variable upon sending and go into the send part only if session is not set.

  if(!isset($_SESSION[$reciever]))
    {
       $_SESSION[$reciever] = 1;
       \\mail code here
    }
  else{
        echo "doing it more than once";
     }

Also you can set $mailer->$SingleTo to true, so you would know if its multiple execution or single. You could also send the timestamp with the email for more debugging.

Ivan Gasparetto

I had the same problem but using the SMTP connection. I still don't know why but it happens when your recipient doesn't have a name. So, instead of

$mailer->AddAddress($receiver);

Do

$mailer->AddAddress($receiver, 'Receiver name');

I hope it helps.

I was experiencing the same problem. In my case changing mail systems did the trick.

By default, phpMailer sends out email using Mail. Once I told it to use Sendmail instead, I stopped getting the duplicate address.

$email = new phpmailer;
$email->mailer = "sendmail";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!