From email address

Created on 25 January 2023, almost 2 years ago
Updated 31 January 2023, almost 2 years ago

Hi,

Is there a way to change the 'from' email address?

I'm using PHPMailer SMTP to send all system emails through google SMTP. The google account I'm using for SMTP is, say, jeff@xxx.com

Emails send fine, but the 'from' email address is always jeff@xxx.com, which I don't want displayed.

The system email address is set as no-reply@xxx.com, which is what I want displayed on all emails. The 'from' name displays as expected as the site name.

I've tried changing all the options under 'Envelope Sender Settings", even specifying 'Envelope sender address' as no-reply@xxx.com, but it doesn't change anything.

I've been able to change the reply-to email, but not the 'from'.

💬 Support request
Status

Closed: works as designed

Version

2.2

Component

Code

Created by

🇨🇦Canada jglynn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jglynn
  • 🇨🇦Canada jglynn

    To answer my own question, I was able to change the 'from' address by going into the settings for my Gmail account and changing the 'send email as' setting to no-reply@xxx.com.

    I would have thought this would be possible through the module settings.

  • 🇦🇺Australia imclean Tasmania

    The "From" header email address is whatever the sending module sets it to. For example, the Webform module allows you to specify the "From" address in a mail handler. PHPMailer SMTP won't change the header, it passes it through as requested.

    You can do this in code using hook_mail_alter(), setting $message['headers']['From'] = 'no-reply@xxx.com';.

    That said, Google might not allow you to send from a different email address than the one associated with the account, which means the From address will always be jeff@... You can check this by using a different SMTP server.

    The envelope sender (the SMTP command "MAIL FROM") address is where bounce messages are sent. The recipient's mail server adds the "Return-path" header based on this address.

  • Status changed to Fixed almost 2 years ago
  • 🇦🇺Australia imclean Tasmania
  • Status changed to Closed: works as designed almost 2 years ago
  • 🇦🇺Australia imclean Tasmania
Production build 0.71.5 2024