How to change envelope sender address using phpmailer?

前端 未结 4 1573
鱼传尺愫
鱼传尺愫 2020-12-10 19:08

With php mail() I can write

mail(\'to@example.com\',\'subject!\',\'body\',\'From: from@example.com\',\'-f from@example.com\');

But how can

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 19:20

    What worked for me (obscurely) using

    $mail->SetFrom('name@yourdomain.com', 'Rupert Bear');
    

    was to use localhost rather than directly access the smtp server e.g.

    $email->Host='localhost'; // SMTP server this way you get from name (don't know why)
    

    Now mails arrive in Outlook from 'Rupert Bear' [name@yourdomain.com]

提交回复
热议问题