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

Support multiple headers with same key #289

Closed
rvman opened this issue Aug 21, 2020 · 4 comments
Closed

Support multiple headers with same key #289

rvman opened this issue Aug 21, 2020 · 4 comments

Comments

@rvman
Copy link

rvman commented Aug 21, 2020

I've run into a situation where I need to be able to apply several headers with the same key to an email, but it seems that the internals for adding headers to an email is defined as a Map, which precludes duplicates.

Is there a way to add the same header multiple times with different values?

Perhaps making the value of EmailBuilder.withHeader() accept a List as the second argument, which would get converted into the same header repeated for each item in the list?

@bbottema
Copy link
Owner

Hi, sorry for the late reply, this report slipped away from me I think.

So you might not need this anymore, but I would like to explore your use case a bit. I can't think of a situation where you would want duplicate headers with different values. I'm not even sure those headers are maintained when sending and reading them back. Can you shed some light on this, please?

@rvman
Copy link
Author

rvman commented Feb 16, 2021

Hello,

I've worked around the issue for now, but it would still be a nice to have.

Duplicate headers are maintained through the SMTP transmission process (eg: the "Received" header), so it's certainly a valid use case.

However, in my scenario, we're using an ESP (Email Service Provider), mailgun in this case, that allows us to provide additional tags/metadata on emails we send via their SMTP gateway for analytics purposes.

The header form is basically: "X-Mailgun-Tag: ", with multiple tags specified by simply duplicating the header key and providing different values.

I suspect other ESPs may also have functionality that operates similarly.

@bbottema
Copy link
Owner

Indeed the RFC allows for duplicate optional-field headers, which means any header name other than then ones specified by the RFC.

@bbottema bbottema added this to the 6.4.6 milestone Feb 16, 2021
bbottema added a commit that referenced this issue Feb 16, 2021
@bbottema bbottema changed the title Multiple headers with same key Support multiple headers with same key Feb 16, 2021
@bbottema
Copy link
Owner

Released in 6.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants