Search code examples
rubyimap

What's the difference between the sender and the from field in Net::IMAP::Envelope?


If you look at the doc for Net::IMAP::Envelope here

http://www.ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html

the struct includes these two fields:

from:   Returns an array of Net::IMAP::Address that represents the from.
sender: Returns an array of Net::IMAP::Address that represents the sender.

What's the difference between these two fields, conceptually?


Solution

  • You're seeing fields that IMAP parsed from the email message itself. From Wikipedia's Email: Header fields:

    From: The email address, and optionally the name of the author(s). In many email clients not changeable except through changing account settings.

    Sender: Address of the actual sender acting on behalf of the author listed in the From: field (secretary, list manager, etc.).

    There's also Reply-To which has to be considered when you want to reply to a message:

    Reply-To: Address that should be used to reply to the message.

    There is a bit more discussion on that page about spoofing and attempts by the MTA (server) to avoid and detect it, but the above is the gist of the info.