Comments (9)
Yeah, not entirely surprising. (SendGrid's v3 API actively prevents multiple reply-to addresses, so it doesn't seem likely they'd handle multiple from emails.)
You got me curious, though, and I ran some quick tests to see which ESPs would even support the from_email='[email protected], [email protected]'
form:
- Mailgun allows multiple from fields
- Mandrill's API doesn't have any way to express more than one from
- Postmark accepts multiple addresses in its From field, but silently truncates to just the first one before sending
- SendGrid's v3 API doesn't have any way to express more than one from
- SparkPost allows a comma-separated from string
But: even if you switched to an ESP that supports them, you'd probably run into deliverability issues with multiple from addresses. Gmail flat-out rejects the message ("5.7.1 Messages with multiple addresses in From: header are not accepted. - gsmtp"). Outlook.com accepts the message, but seems to consider multiple from addresses a spam signal (my tests ended up in the junk folder).
For completeness, I think I'm going to change Anymail to support a multi-address from_email string for Mailgun and SparkPost, and to issue a clearer "unsupported" error for the other ESPs. But in practice, multiple from addresses probably aren't all that usable.
For your project, one approach I've seen with forwarding is encoding one email address in another. E.g.: From: support+customer%[email protected]
. (Assuming company.com's mail supports +-aliases, that delivers to [email protected]
, but you can still extract the "other from" from the address.)
from django-anymail.
Oh, wow, I didn't know the RFC allowed multiple addresses in the From field. Learned something new today.
Anymail extends Django's EmailMessage
class, which is specced to take a single string as its from_email
. So that's not something Anymail could change unilaterally. You could submit a proposed change to Django, and if accepted Anymail would follow the change.
But FWIW, most (maybe all?) of the ESPs Anymail supports only allow a single from address in their APIs. So even if Django's EmailMessage allowed multiple from emails, they'd just turn into AnymailUnsupportedFeature errors.
Can I ask how you're trying to use multiple from emails? There might be some other way to achieve a similar outcome. (E.g., the EmailMessage reply_to
allows a list of emails, and this works with all Anymail ESPs except SendGrid.)
from django-anymail.
@medmunds The scenario I am running into is with a pseudo mail forwarding feature I have developed.
That features generates a from_email
as follows: From:'"[email protected]" <[email protected]>
. The reasons for this scenario is rather long and specific. However, reading the RFC spec led me to explore a mailbox-list from_email option.
Exploring Django's EmailMessage source, I see that the message object from
can be assigned using the extra_headers
dict. I can see if I can explore an option around that.
If the issue is with Django I can consider opening a ticket there. Although Django's core message functionality seems to allow for it. I could be wrong.
Thanks again for making the project regardless. This is a wonderful library to use and I am grateful it exists.
from django-anymail.
Hmm, couple of things:
-
from_email='"[email protected]" <[email protected]>'
should work just fine. That is, from_email is a single string, with a single email address (mailbox) whose display-name is "[email protected]" and whose addr-spec is "[email protected]". (And that's a good approach if you're trying to change how the "From" is displayed in the recipient's email client.) -
Looking more closely, I see that Anymail is imposing an additional requirement on
from_email
that Django core email doesn't: Django would allowfrom_email='[email protected], [email protected]'
βstill a single string (not a Python list), but with multiple, comma-separated emails in it. And it would pass that string, more-or-less intact, on to the underlying email backend as the From header.
I can look at making that work in Anymail. But the problem is still going to be that most ESP send APIs don't allow multiple from addresses. And they tend to be pretty picky about allowing header overrides of standard fields like From. So it'll probably just be a different error getting raised.
Which ESP(s) are you using?
from django-anymail.
@medmunds We are currently using SendGrid. I just got off chat support with them. They appear to only support one email address-spec in the From field. Ugh. Not sure if other ESP's provide it.
If you feel like closing the ticket that's fine. I will initiate a feature request with SendGrid to see if they can allow for that. Likely wouldn't be addressed anytime soon though.
from django-anymail.
@medmunds Thanks again for the help with creative solutions on my specific scenario. And for the responsiveness to the issue I created on the repo.
from django-anymail.
@avelis no problem - thanks
from django-anymail.
Exception Value: | Invalid address; only [email protected] could be parsed from [email protected],[email protected]"
I am getting the above error while using in to or cc .
from django-anymail.
@ajeetgupt1982 I appreciate your searching for related issues before opening a new one, but it sounds like you are seeing something different. This issue is specifically about multiple from_email
addresses, not to
or cc
.
If you're having trouble with multiple recipients, please open a new issue (or ask a question on Stack Overflow), and be sure to include all of the information requested. In particular, which ESP, what version of Anymail, your code that tries to send the email, and the exact and complete error message. (The exception value you posted above doesn't appear in Anymail's code. There is a similar error, though, and if that's the one you're seeing, then you've added text and changed some important details as you pasted it here.)
You may also want to take a look at the help page in Anymail's docs, if you haven't already.
from django-anymail.
Related Issues (20)
- parse_address_list: Inability to Parse Email Addresses with Special Characters in Display Name Without Double-Quote Encapsulation HOT 1
- Mailjet Open tracking? HOT 4
- Inaccuracy in documentation about Brevo's behaviour HOT 2
- Feature request: Mailtrap HOT 4
- Resend: confusing ReadTimeout error for incorrect API key
- Add support to Unisender Go HOT 2
- Support Brevo batch sending with merge_data HOT 2
- Add batch sending support for Resend HOT 1
- Mailgun webhooks: AttributeError 'NoneType' object has no attribute 'get' HOT 1
- boto3 sesv2 client does not have method 'send_email'. Check AmazonSESV2SendEmailPayload HOT 4
- Bad UTF-8 "To" header encoding? HOT 8
- Tests fail with error "AppRegistryNotReady: Apps aren't loaded yet"
- Tests fail with error "django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet" HOT 4
- New feature: per-recipient merge_headers
- Amazon SES: support extra_headers, metadata, tags for template sends
- Brevo `trace_clicks` and `trace_opens` HOT 2
- `ses:SendRawEmail` permission still required in v11 for Amazon SES when using `django.core.mail.send_mail`? HOT 3
- Brevo Webhook Mapping Updates HOT 4
- A boto3 problem? HOT 5
- Mailgun Inbound: Empty Attachments When Receiving Emails from Gmail Web HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-anymail.