Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Amazon Simple Email Service _SES_
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
Extensions
Amazon Simple Email Service _SES_
Commits
64344002
Commit
64344002
authored
2 months ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Fix Bcc mail
parent
5ec39f02
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Ses/Mail.php
+45
-3
45 additions, 3 deletions
CRM/Ses/Mail.php
with
45 additions
and
3 deletions
CRM/Ses/Mail.php
+
45
−
3
View file @
64344002
...
...
@@ -71,13 +71,55 @@ class CRM_Ses_Mail extends Mail {
}
}
// Sanitize and prepare headers for transmission
if
(
!
is_array
(
$headers
))
{
return
new
PEAR_Error
(
'SES: $headers must be an array'
);
}
$ses_access_key
=
Civi
::
settings
()
->
get
(
'ses_access_key'
);
$ses_secret_key
=
Civi
::
settings
()
->
get
(
'ses_secret_key'
);
$ses_region
=
Civi
::
settings
()
->
get
(
'ses_region'
);
// Sanitize and prepare headers for transmission
if
(
!
is_array
(
$headers
))
{
return
new
PEAR_Error
(
'SES: $headers must be an array'
);
// $headers['Bcc'] gets unset before calling this function because it assumes it won't get removed by the mailer.
// But SES needs the full headers and then it removes it when processing.
// So we have to add it back in. We can get it from the last element in the $recipients array:
// $recipients = [
// 0: To (single email)
// 1: Cc (comma separated string)
// 2: Bcc (comma separated string)
// ]
// BUT BE CAREFUL! To or Cc might not be defined so it won't always be element 2. It will always be the last element
// but we don't know if we actually have any Bcc addresses without checking the To, Cc headers first.
// Eg. if you have To+Bcc then $recipients[0] is To and $recipients[1] is Bcc but if you have To+Cc then $recipients[1]
// is Cc and if $recipients[2] is not set you have no Bcc and don't need to add the header... confused yet?
// Work out which $recipients keys represent To, Cc and Bcc
if
(
array_key_exists
(
'To'
,
$headers
))
{
$newRecipients
[
'To'
]
=
array_shift
(
$recipients
);
}
if
(
array_key_exists
(
'Cc'
,
$headers
))
{
$newRecipients
[
'Cc'
]
=
array_shift
(
$recipients
);
}
$newRecipients
[
'Bcc'
]
=
array_shift
(
$recipients
);
if
(
!
empty
(
$newRecipients
[
'Bcc'
]))
{
// The order of headers might not matter (I didn't check if SES cares or not).
// But we insert the Bcc header in the right place anyway. ie. after Cc or To or From.
if
(
array_key_exists
(
'Cc'
,
$headers
))
{
$insertBccAfterHeader
=
'Cc'
;
}
elseif
(
array_key_exists
(
'To'
,
$headers
))
{
$insertBccAfterHeader
=
'To'
;
}
else
{
$insertBccAfterHeader
=
'From'
;
}
foreach
(
$headers
as
$headerKey
=>
$headerValue
)
{
$newHeaders
[
$headerKey
]
=
$headerValue
;
if
(
$headerKey
===
$insertBccAfterHeader
)
{
$newHeaders
[
'Bcc'
]
=
$newRecipients
[
'Bcc'
];
}
}
$headers
=
$newHeaders
;
}
$this
->
_sanitizeHeaders
(
$headers
);
...
...
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