Answers.Body: <p>JMA had two loosely related clients that were on the same server. See gist <a href="https://gist.github.com/JoeMurray/0d8663e9f034c0b5e23b123e75c9fa07" rel="nofollow noreferrer">https://gist.github.com/JoeMurray/0d8663e9f034c0b5e23b123e75c9fa07</a> 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-28T11:05:59.050Z
Answers.Text: I dont code, so this is slightly useful and shows I think the kind of process.
Answers.UserDisplayName: Peter Turner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-21T19:11:06.980Z
Answers.LastActivityDate: 2021-12-21T19:11:06.980Z
Answers.UserDisplayName: Joe Murray
Answers.Body: <p>Yes you should be able to alter the headers using alterMailParams() hook</p>
  <pre><code>function notify_civicrm_alterMailParams(&amp;$params, $context) {
    $params['headers']['headervaraible'] = 'XXXXX';
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-19T14:13:53.190Z
Answers.Text: Thanks at least I'm on the right lines...   However, not sure where to start with implementing this..
Answers.UserDisplayName: Peter Turner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-21T20:13:25.030Z
Answers.Text: You'll also need to think about bounce processing as you will need to be checking mail boxes on each of the 3 domains.
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-17T13:51:20.950Z
Answers.LastActivityDate: 2021-12-17T13:51:20.950Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>The first thing here is to disambiguate the &quot;From Address&quot;, which unfortunately has two separate definitions</p>
  <p>There is the 'envelope From' or 'smtp from' which is normally generated by CiviMail using the domain configured in Administer -&gt; Civimail -&gt; Mail Accounts. That &quot;from&quot; 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).</p>
  <p>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.</p>
  <p>Until you specify what you're referring too, I'm concerned this issue will just generate confusion and misleading advice.</p>
  <p>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:</p>
  <p><a href="http://homeofficekernel.blogspot.com/2020/11/successful-mass-mailing.html" rel="nofollow noreferrer">http://homeofficekernel.blogspot.com/2020/11/successful-mass-mailing.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-28T11:03:35.770Z
Answers.Text: It the envelope From I want to change, so it matches the header from.
Answers.UserDisplayName: Peter Turner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-30T23:25:01.053Z
Answers.Text: 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.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-22T16:46:06.943Z
Answers.LastActivityDate: 2021-12-22T16:46:06.943Z
Answers.UserDisplayName: Alan Dixon
Body: <p>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.</p>
  <p>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
  <a href="https://civicrm.stackexchange.com/questions/22984/is-it-possible-to-configure-civimail-to-send-from-two-different-domains">Is it possible to configure CiviMail to send from two different domains?</a></p>
  <p>Has anybody implemented this and able to assist me.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-19T21:12:30.323Z
Comments.Text: have you set up DKIM and SPF for all 3?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-21T11:39:20.050Z
Comments.Text: yes - but the repsond domain remains the same a Civi site - so I need a way to alter based on the sending domain
Comments.UserDisplayName: Peter Turner
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-22T16:47:38.027Z
Comments.Text: 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.
Comments.UserDisplayName: Alan Dixon
Tags: <civimail><domain>
Title: Allow single site install to send from Multiple Domains using alterMailParams
ThreadText: # Allow single site install to send from Multiple Domains using alterMailParams
  
  (Asked by: username_0 on 2021-12-17)
  
  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?](https://civicrm.stackexchange.com/questions/22984/is-it-possible-to-configure-civimail-to-send-from-two-different-domains)
  
  Has anybody implemented this and able to assist me.
  
  **Tags:** civimail, domain
  
  > **Comments:**
  > **username_1**: have you set up DKIM and SPF for all 3?  
  > **username_0**: yes - but the repsond domain remains the same a Civi site - so I need a way to alter based on the sending domain  
  > **username_2**: 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.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2021-12-21. Score: 2
  
  JMA had two loosely related clients that were on the same server. See gist <https://gist.github.com/username_3/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.
  
  > **Comments:**
  > **username_0**: I dont code, so this is slightly useful and shows I think the kind of process.  
  
  ---
  
  ### Answer by username_4 on 2021-12-17. Score: 1
  
  Yes you should be able to alter the headers using alterMailParams() hook
  
  ```
  function notify_civicrm_alterMailParams(&$params, $context) {
    $params['headers']['headervaraible'] = 'XXXXX';
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks at least I'm on the right lines...   However, not sure where to start with implementing this..  
  > **username_5**: You'll also need to think about bounce processing as you will need to be checking mail boxes on each of the 3 domains.  
  
  ---
  
  ### Answer by username_2 on 2021-12-22. Score: 0
  
  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:
  
  <http://homeofficekernel.blogspot.com/2020/11/successful-mass-mailing.html>
  
  > **Comments:**
  > **username_0**: It the envelope From I want to change, so it matches the header from.  
  > **username_2**: 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.  
  
  ---
  
  