Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:22:28+00:00 2026-06-14T23:22:28+00:00

Question about InboundMailHandler. class MailHandle(InboundMailHandler): def receive(self, mail_message): mail_message.sender may contained John Bolton <john78@mail.com>.

  • 0

Question about InboundMailHandler.

class MailHandle(InboundMailHandler):
  def receive(self, mail_message):

mail_message.sender may contained "John Bolton <john78@mail.com>". How can i extract "john78@mail.com" from it?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:22:29+00:00Added an answer on June 14, 2026 at 11:22 pm

    I’ve been using this regex, which works very well. It might theoretically be possible to engineer a sender which fails this regex, that’s why I catch the exception and alert about the address. It has not happened yet though.

    try:
        sender = re.search('<?([^<>]+)>?$',mail.sender).group(1)
    except AttributeError:
        ...
    

    The other answer is not compatible with the official email address format, as defined per RFC 2822.

    Normally, a mailbox is comprised of two parts: (1) an optional display
    name that indicates the name of the recipient (which could be a person
    or a system) that could be displayed to the user of a mail
    application, and (2) an addr-spec address enclosed in angle brackets
    ("<" and ">"). There is also an alternate simple form of a mailbox
    where the addr-spec address appears alone, without the recipient’s
    name or the angle brackets.

    Please note that this snippet mentions recipients, but if you read the spec, it applies to senders also.

    https://www.rfc-editor.org/rfc/rfc2822#section-3.4

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question about subclassing in matlab, under the new class system. I've got class A
A question about inheritance in java... class Base { private int val = 10;
Question about controllers. Can controller call it`s own class methods inside an action? EDIT:
Simple question about Jquery-UI sortable lists (http://jqueryui.com/demos/sortable/#default) I have made: <ul id=sortable> <li class=ui-state-default>An
Question about DOM* class createXXX methods in C++. Do I have to do anything
a question about class design. Currently I have the following structure: abstract Base Repository
Question about GridView sorting in VB.NET: I have a GridView with AutoGenerateColumns = True
Question about logics here: What's the most elegant way to make the menu appear/disappear
Question about assignments and variables (* For example *) SP = SparseArray[{},5] or SP
one question about PHP Development. I am building up some Form Fields for Calculations.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.