Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mailer/AWS] Custom headers aren't transmitted #45168

Closed
KDederichs opened this issue Jan 25, 2022 · 13 comments · Fixed by symfony/symfony-docs#19455 · May be fixed by #58761
Closed

[Mailer/AWS] Custom headers aren't transmitted #45168

KDederichs opened this issue Jan 25, 2022 · 13 comments · Fixed by symfony/symfony-docs#19455 · May be fixed by #58761

Comments

@KDederichs
Copy link
Contributor

Symfony version(s) affected

5.4.2

Description

When trying to send a custom header towards AWS using the AsyncAws implementation custom headers aren't included.
This seems to be due to the usage of the Simple message format that doesn't seem to allow for custom headers:
https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_SendEmail.html

Upon printing the Api request the headers are nowhere to be found either.

How to reproduce

Add a header to the mail via:
$message->getHeaders()->addTextHeader('x-test', 'test'));
and send it using the ses+api DSN

Possible Solution

There seems to be a Raw message format you can send that allows for custom headers so the package should probably use that.

Additional Context

No response

@drekinov
Copy link

drekinov commented Apr 29, 2022

that not documented behaviour lead to lost of data for last 21 months. (or i miss something in documentation)
obviously not most important feature because no one complaint about it.
we switched to ses+https:// and will see if there are any further regressions.
we used custom driver with AWS SDK V3 until 2020-07 when we switched to AsyncAws transport .. and got busted

@fabpot
Copy link
Member

fabpot commented Aug 5, 2022

Is anyone willing to investigate a fix (if that's possible)?

@bogdanbradeanu
Copy link

bogdanbradeanu commented Dec 23, 2022

we've been hit the same issue and according to AWS docs https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_SendEmail.html, content node has 3 types raw/simple/template, sending via simple ignores all custom headers.

Each mailer transport uses a different type to send. see https://github.com/symfony/amazon-mailer/blob/6.2/Transport/SesApiAsyncAwsTransport.php

ses+https:// uses RAW type

'Content' => [
                'Raw' => [
                    'Data' => $message->toString(),
                ],
            ],

ses+api DSN uses Simple type

'Content' => [
                'Simple' => [
                    'Subject' => [
                        'Data' => $email->getSubject(),
                        'Charset' => 'utf-8',
                    ],
                    'Body' => [],
                ],
            ],

i've swapped locally to RAW and it works as intended.

@xabbuh
Copy link
Member

xabbuh commented Jan 4, 2023

@bogdanbradeanu Are you up for a PR?

@stof
Copy link
Member

stof commented Jan 4, 2023

Well, the Raw type is already supported. That's what the ses+https scheme does in the DSN.
Changing ses+api to be the same implementation does not make sense.

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@stof
Copy link
Member

stof commented Jul 5, 2023

to me, we should either deprecate the ses+api transport or document the status quo.

@carsonbot carsonbot removed the Stalled label Jul 5, 2023
@KDederichs
Copy link
Contributor Author

I'd be good if it was documented somewhere tbh. That would already help, since as it stands now you either know that behaviour or you don't.
Though deprecation would also work if the two are equal in features otherwise.

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

@ddebin
Copy link

ddebin commented Jan 24, 2024

It's still a problem, I can't send a message with custom headers with a ses+api DSN. The documentation should clearly state this shortcoming and suggest using ses+https.

@carsonbot carsonbot removed the Stalled label Jan 24, 2024
@xabbuh
Copy link
Member

xabbuh commented Jan 24, 2024

Well, someone who understands the issue and shortcomings will have to come up with a PR adding this piece of documentation.

@KDederichs
Copy link
Contributor Author

Let me know if that does the trick or if it needs more information in there.

javiereguiluz added a commit to symfony/symfony-docs that referenced this issue Jan 25, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[Mailer] Add warning about custom SES headers

Fixes symfony/symfony#45168 by mentioning that the provider needs to be ses+https in order to transmit custom headers.

Commits
-------

cb44ce9 Add warning about custom SES headers
@xabbuh xabbuh closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants