daniel-zahariev / php-aws-ses

PHP classes that interfaces Amazon Simple Email Service
307 stars 100 forks source link

How to set custom header or tags to use with Amazon Cloud Watch and get real metrics. #49

Closed osalas891123 closed 6 years ago

osalas891123 commented 6 years ago

Need to set custom email headers or email tags to work together with Amazon Cloud Watch and sent events. Is this possible with the library

jdrydn commented 6 years ago

@daniel-zahariev Wondering this too.

I'm trying to send emails via a configuration set, however I'm seeing inconsistent results. Some emails are sent through the dedicated IP and some emails are still sent through the shared IP pool.

I'm adding the relevant custom header as per this documentation:

$ses = new SimpleEmailService(AWS_ACCESS_KEY, AWS_SECRET_KEY, SimpleEmailService::AWS_EU_WEST1, true);
$ses->enableVerifyPeer(false);
$ses->setBulkMode(true);
$message = new SimpleEmailServiceMessage();
// ...
$message->addCustomHeader('X-SES-CONFIGURATION-SET: ConfigSet');
$ses->sendEmail($message, true);

Adding the following debug line will prepend the headers to the top of the raw messages, as expected:

print_r(base64_decode($message->getRawMessage()));
X-SES-CONFIGURATION-SET: ConfigSet
To:{{ removed }}
From: {{ removed }}
Subject: {{ removed }}
MIME-Version: 1.0
Content-type: Multipart/Mixed; boundary="..."

Unsure if there's a bug going on here or if I should revert to the standard AWS-SES SDK since my use-case now involves a configuration set? Any advice would be much appreciated!

brod-ie commented 6 years ago

Having the same issue

daniel-zahariev commented 6 years ago

Thanks everyone for reporting this. I've just added support for SES Configuration Set and Message Tags in the latest release (0.9.1). While working on it i found that Configuration sets are not global but per region and until i realised this i was banging my head why is it saying that the configuration set is missing.

jdrydn commented 6 years ago

@daniel-zahariev Thanks for this. I can see you set ConfigurationSetName in the SES request, and I can see the relevant header being set in the getRawMessage method, but I'm still getting emails being sent through the shared IP pool. I've reached out to AWS to see if they can identify an incorrect setting with my SES setup & I'll update this thread with the outcome.