-1

I'm using the PHPMailer library for sending emails. Everything is working just fine except for one small problem. I have a default gmail account that is used to most my clients as a SMTP Auth.

$mail->Host = 'ssl://smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = 'email@gmail.com';
$mail->Password = 'gmail**pass';

However, when I setup the FROM that it was supposed to use, it uses my GMAIL instead of the defined FROM as a reply-to and that never happened before. I thought it might be some php.ini setting, but looking into the phpinfo(), nothing caught my attention.

$mail->From = 'contact@client.com';
$mail->FromName = 'Client Name';

Does anyone have any idea what that might be?

Caio Favero
  • 2,196
  • 3
  • 17
  • 18
  • Set the `$mail->ReplyTo` value – Martin Mar 06 '18 at 20:05
  • Second call: don't change the address; sending from another address that is not the sender is asking to be marked as spam. The mail envelopes will notice this difference and it's going to look suspicious to the receiver. – Martin Mar 06 '18 at 20:06

1 Answers1

4

Gmail will not permit you to set a From address unless it's in your Gmail settings as a verified email alias (they overwrite it to be your Gmail address). Even if they would, doing so would generally get your email flagged as spam, because in most situations Gmail isn't going to be set up as a valid sender in the domain's SPF records.

Leave From as an address under your control, and set the Reply-To header instead to direct replies to the right address.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • 1
    Great answer here, and it does address the post... but, why did you go and post an answer *after* you hammered it? – Funk Forty Niner Mar 06 '18 at 20:20
  • @FunkFortyNiner I posted the answer first, as the timestamp indicates. Marked it as a dupe because I found the dupe when Googling up the official word from Google that they do this. – ceejayoz Mar 06 '18 at 20:28