Giter Club home page Giter Club logo

Comments (9)

medmunds avatar medmunds commented on May 24, 2024 1

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.

medmunds avatar medmunds commented on May 24, 2024

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.

avelis avatar avelis commented on May 24, 2024

@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.

medmunds avatar medmunds commented on May 24, 2024

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 allow from_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.

avelis avatar avelis commented on May 24, 2024

@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.

avelis avatar avelis commented on May 24, 2024

@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.

medmunds avatar medmunds commented on May 24, 2024

@avelis no problem - thanks

from django-anymail.

ajeetgupt1982 avatar ajeetgupt1982 commented on May 24, 2024

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.

medmunds avatar medmunds commented on May 24, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.