PHPMailer / PHPMailer

The classic email sending library for PHP
GNU Lesser General Public License v2.1
20.77k stars 9.7k forks source link

setFrom didn't work as expected #3016

Closed hafizewp22 closed 4 months ago

hafizewp22 commented 4 months ago

Please check these things before submitting your issue:

Problem description

The expected working of function setFrom is set a header indicate the from field. But in the received mail, it shows the from address as the authenticated gmail address.

Code to reproduce

Screenshot 2024-02-12 at 15 00 34

Debug output

Screenshot 2024-02-12 at 15 07 51
Synchro commented 4 months ago

As the docs say, gmail doesn't let you forge from addresses. If you use anything other than your account address or a predefined alias, the from address will just be ignored. The right way to handle this is shown in the contact form example.