Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Developer Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
brienne
Developer Documentation
Commits
9769f7a1
Commit
9769f7a1
authored
5 years ago
by
Rich
Browse files
Options
Downloads
Patches
Plain Diff
Improve hook_civicrm_alterMailParams re: headers and flexmailer. fix #654
parent
73faadd9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/hooks/hook_civicrm_alterMailParams.md
+29
-5
29 additions, 5 deletions
docs/hooks/hook_civicrm_alterMailParams.md
with
29 additions
and
5 deletions
docs/hooks/hook_civicrm_alterMailParams.md
+
29
−
5
View file @
9769f7a1
...
...
@@ -2,7 +2,7 @@
## Summary
This hook is called when an email is
about to be sent
by CiviCRM.
This hook is called when an email is
being prepared for sending
by CiviCRM.
## Definition
...
...
@@ -12,7 +12,10 @@ This hook is called when an email is about to be sent by CiviCRM.
-
$params - the mailing params array
-
$context - the contexts of the hook call are:
-
"civimail" for when sending an email using civimail,
-
"civimail" for when sending an email using CiviMail,
-
"flexmailer" for when sending an email using CiviMail and
[
FlexMailer
](
https://civicrm.org/extensions/flexmailer
)
(e.g. for Mosaico),
-
"singleEmail" for when sending a single email,
-
"messageTemplate" for when sending an email using a message
template
...
...
@@ -20,7 +23,28 @@ This hook is called when an email is about to be sent by CiviCRM.
## Details
-
$params array fields include: groupName, from, toName, toEmail,
subject, cc, bcc, text, html, returnPath, replyTo, headers,
attachments (array)
subject, cc, bcc, text, html, returnPath, replyTo, headers
(array)
,
attachments (array)
, and possibly others depending on context.
-
If you want to abort the mail from being sent, set the boolean
abortMailSend to true in the params array
abortMailSend to true in the params array
-
Note that this hook is called twice when sending a message template, once
early in the message generation (before tokens are applied, with the context
`messageTemplate`
) and then later from
`CRM_Utils_Mail::send()`
with the
context
`singleEmail`
.
## Adding custom headers to the email
You can add custom headers by appending to
`$params['headers']`
. Example:
$params['headers']['X-My-Header'] = 'my header value';
Note: the
`headers`
key may not exist in the
`$params`
array when passed into
the hook.
For CiviMail based emails you can also add headers by simply adding a key
directly to the
`$params`
array, however as CiviMail also supports the above, so
it might be safer to use the
`headers`
key when adding headers as this is
supported across all methods.
Study the source before atttempting to set or unset non-custom headers this way!
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment