You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue when using gen_smtp where providing an address that's a tuple or contains a name causes the SMTP server (AWS SES in this case) to return an invalid email error. The fix is to extract the address from the tuple/string with name. I'm curious if introducing something like get_address(message, header) makes sense for this project. I'd expect this to be a common problem for folks.
Here's an example of the problem I'm referring to.
You can fix the the problem by making both from and to plain addresses instead of the name/address combo. However, the From and To headers now won't contain the name. This puts the burden on the users of mail to figure this out.
My proposal is to provide a get_address/2 function that would provide this functionality.
message=Mail.build()|>Mail.put_from("Me <[email protected]>")|>Mail.put_to("You <[email protected]>")|>Mail.put_subject("Hello, you!")|>Mail.put_text("Sup")from=Mail.get_address(message,:from)# returns "[email protected]"to=Mail.get_address(message,:to)# returns "[email protected]"body=Mail.render(message):gen_smtp_client({from,to,body},config)# it works 🎉
We've implemented something similar in our project and I'd be happy to provide a PR.
The text was updated successfully, but these errors were encountered:
I've run into an issue when using
gen_smtp
where providing an address that's a tuple or contains a name causes the SMTP server (AWS SES in this case) to return an invalid email error. The fix is to extract the address from the tuple/string with name. I'm curious if introducing something likeget_address(message, header)
makes sense for this project. I'd expect this to be a common problem for folks.Here's an example of the problem I'm referring to.
You can fix the the problem by making both
from
andto
plain addresses instead of the name/address combo. However, theFrom
andTo
headers now won't contain the name. This puts the burden on the users ofmail
to figure this out.My proposal is to provide a
get_address/2
function that would provide this functionality.We've implemented something similar in our project and I'd be happy to provide a PR.
The text was updated successfully, but these errors were encountered: