We have a singe site Civi install and send mailing from 3 different domains using 1 of the addresses From Email Address Options, however the header information in the email is always the primary domain name. This is causing many emails to be marked as junk.

I have done some investigation and multi-site seems over kill as a resolution and I found some mention of using alterMailParams hook to control the sender. ref Is it possible to configure CiviMail to send from two different domains?

Has anybody implemented this and able to assist me.

  • have you set up DKIM and SPF for all 3?
    – petednz - fuzion
    Commented Dec 19, 2021 at 21:12
  • yes - but the repsond domain remains the same a Civi site - so I need a way to alter based on the sending domain Commented Dec 21, 2021 at 11:39
  • The Email From Address Options is not the primary issue for deliverability. See my answer below for a discussion of disambiguating your 'from address' here.
    – Alan Dixon
    Commented Dec 22, 2021 at 16:47

3 Answers 3


Yes you should be able to alter the headers using alterMailParams() hook

function notify_civicrm_alterMailParams(&$params, $context) {
  $params['headers']['headervaraible'] = 'XXXXX';
  • Thanks at least I'm on the right lines... However, not sure where to start with implementing this.. Commented Dec 19, 2021 at 14:13
  • You'll also need to think about bounce processing as you will need to be checking mail boxes on each of the 3 domains. Commented Dec 21, 2021 at 20:13

JMA had two loosely related clients that were on the same server. See gist https://gist.github.com/JoeMurray/0d8663e9f034c0b5e23b123e75c9fa07 for the diff created about a year ago of the changes made to support this. I've obfuscated the client names but hopefully not mangled anything else. We didn't publish since this was a one-off, but maybe this will give you a starting place.

  • I dont code, so this is slightly useful and shows I think the kind of process. Commented Dec 28, 2021 at 11:05

The first thing here is to disambiguate the "From Address", which unfortunately has two separate definitions

There is the 'envelope From' or 'smtp from' which is normally generated by CiviMail using the domain configured in Administer -> Civimail -> Mail Accounts. That "from" is not normally directly seen by the recipient, but is used for deliverability and bounce handling (and yes, can sometimes be seen by the recipient as well).

Then there is the 'header from' which is what the recipient sees and is less relevant in terms of deliverability (but still matters for different reasons), but also matters for optics and replies. That's the one you configure in the CiviMail From Addresses.

Until you specify what you're referring too, I'm concerned this issue will just generate confusion and misleading advice.

I think in your case, you want a system administrator to sort out the smtp-from issue and the deliverability. You should be able to put lots of different header-from addresses with different domains, but of course, it depends. Here's my more complicated long advice:


  • It the envelope From I want to change, so it matches the header from. Commented Dec 28, 2021 at 11:03
  • The envelope from address is generated by CiviMail using the domain of the mail account that you have designated for bounce processing. You don't normally need that to match the header from, they have different purposes.
    – Alan Dixon
    Commented Dec 30, 2021 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.