View Issue Details

IDProjectCategoryView StatusLast Update
0035305mantisbtbugtrackerpublic2025-03-09 12:29
Reporterdevnull Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
Product Version2.27.0 
Summary0035305: PHPMailer - AWS SES (about configuration-set)
Description

Hey guys,

We have a problem sending email through AMAZON SES.
Amazon SES implemented Configuration-Sets (groups of rules to verified identities).
These configuration sets can be created on AmazonSES console or panel.

But using mantisbt PHP Mailer, when trying to send mail, I got on debug the error:

2025-02-07 00:01 -03 MAIL email_api.php:1560 email_send() ERROR: Message could not be sent ... - Configuration Set does not exist: Configuration set <my-first-configuration-set> does not exist.

AmazonSES requires the configuration-set to be sent in the mail header.

I couldn't find any mantisbt configuration where I could send this configuration-set name.
So I manually changed the core/email_api.php file to include the configuration-set in the header:
$t_mail->AddCustomHeader( 'X-SES-CONFIGURATION-SET: main' );

"main" is my configuration set on Amazon SES. After this, sending mail through Amazon SES is working.

The change I made to core/email_api.php will stop working when mantisbt is updated.
So I would like to ask for the possibility of including in config/config_inc.php a new variable to send a custom header, which is necessary in Amazon SES.

Something like:
$g_smtp_customheader = 'X-SES-CONFIGURATION-SET: main'

And internally using this variable inside:
$t_mail->AddCustomHeader( $g_smtp_customheader);
in core/email_api.php

Something like that. Sorry, I'm C programmer (not php programmer), but I hope I managed to explain.

Many thanks!

TagsNo tags attached.

Relationships

related to 0035288 resolvedvboctor Support custom email sending providers 

Activities

dregad

dregad

2025-02-08 11:20

developer   ~0069837

I'm not opposed to the idea. Would you be willing to submit a pull request ?

@vboctor has been working on a new concept of EmailProviders, I'm wondering if that could cover the requirement ? See 0035288

Implementing this would likely introduce a conflict with the pending PR https://github.com/mantisbt/mantisbt/pull/2088

devnull

devnull

2025-02-10 10:31

reporter   ~0069841

Hi @dregad, thanks for your reply!

Sure I can! I opened https://github.com/mantisbt/mantisbt/pull/2092

I don't know, I will test this week @vboctor implementation. I liked the idea.
But I don't see how this could conflict. The vboctor implementation doesn't conflict with PHP Mailer. In fact, many existing $g_smtp*** variables are exclusive to PHP Mailer, and this one would be one more.

dregad

dregad

2025-02-10 11:36

developer   ~0069843

Last edited: 2025-02-10 11:37

What I meant, is that to introduce the new config required to fix your problem, it would probably be necessary to update the same source files as PR 2088, which would likely result in merge conflicts.

I have not actually tested the EmailProviders feature, I just thought that it may be a potential solution to define a specific AmazonSES provider. To be analyzed and tested I guess.

devnull

devnull

2025-02-10 12:29

reporter   ~0069846

Oh yes, sorry for the misunderstanding.
This week I should release the changes to the PR I openned; and I will also test the new EmailProviders feature. I don't know exactly how it works, but it seems pretty interesting.

devnull

devnull

2025-02-10 17:19

reporter   ~0069848

Done dregad! Please take a look at
https://github.com/mantisbt/mantisbt/pull/2092/commits/7206123b9f3664c3cd435387e9ff7e048a6986f4

dregad

dregad

2025-03-09 12:29

developer   ~0069972

@devnull, PR 2088 has now been merged into master and according to @vboctor's recommendation, the improvement you proposed in https://github.com/mantisbt/mantisbt/pull/2092 should be rewritten as a plugin using the new Email Provider functionality.

You can have a custom AwsEmailSender that could inherit from EmailSenderPhpMailer and inject headers based on plugin specific config options.

I'm also repeating Victor's follow-up post below for future reference :

I looked as some of the sender specific headers and there are a bunch that are not static. Hence, the approach suggested in PR 2088 is a superior to static config based global setting, since, using code allows adding logic that sets the headers based on context.

When sending emails via SMTP, different providers support various custom headers to enable specific functionalities. Here’s a summary of provider-specific custom headers for Mailgun, Postmark, AWS SES, and SendGrid:

Mailgun

Mailgun allows the use of custom MIME headers to manage various email features:

Recipient Variables: Use the X-Mailgun-Recipient-Variables header to send personalized content to multiple recipients in a single API call. • Tagging: Apply the X-Mailgun-Tag header to categorize emails for analytics and tracking purposes. • Campaigns: Utilize the X-Mailgun-Campaign-Id header to associate emails with specific campaigns. • Delivery Time: Schedule email delivery using the X-Mailgun-Deliver-By header. • Test Mode: Activate test mode with the X-Mailgun-Drop-Message header to simulate email sending without actual delivery.

Postmark

Postmark supports several custom SMTP headers to enhance email functionality:

Message Stream: Specify the message stream using the X-PM-MESSAGE-STREAM header. If omitted, Postmark defaults to the transactional stream. • Tagging: Assign a tag to an email with the X-PM-Tag header for categorization and analytics. • Open Tracking: Enable or disable open tracking using the X-PM-TrackOpens header. • Link Tracking: Control link tracking with the X-PM-TrackLinks header. • Metadata: Add custom metadata to an email by prefixing headers with X-PM-Metadata-. For example, X-PM-Metadata-Client-ID: 12345 attaches a Client-ID metadata field to the email.

For more details, refer to Postmark’s SMTP documentation. 

Amazon SES

Amazon Simple Email Service (SES) allows the inclusion of custom headers to manage email features:

Custom Headers: As of March 2024, SES supports setting custom headers when sending emails using SES v2 sending APIs, facilitating functionalities like one-click unsubscribe via List-Unsubscribe headers.  • Configuration Sets: Utilize the X-SES-CONFIGURATION-SET header to specify a configuration set that applies to the email, enabling features like open and click tracking. • Message Tags: Apply the X-SES-MESSAGE-TAGS header to add tags to emails for categorization and analytics.

SendGrid

SendGrid supports custom SMTP headers to control various email functionalities:

Unique Arguments: Use the X-SMTPAPI header to include unique arguments for tracking and analytics. • Categories: Assign categories to emails using the X-SMTPAPI header for grouping and analytics. • ASM Group ID: Specify the unsubscribe group with the X-SMTPAPI header to manage unsubscribe preferences. • Scheduling: Schedule email delivery using the X-SMTPAPI header to set a specific send time.

For comprehensive information on SendGrid’s SMTP headers, consult SendGrid’s SMTP API documentation.

When integrating these headers, ensure they are correctly formatted and supported by your chosen SMTP client or library to achieve the desired email functionalities.