IMAP Envelope email address format? - email

If I poll an IMAP server for an Envelope structure SELECT INBOX, FETCH UID ALL - I will get an envelope structure in return.
For all fields in the envelope structure that are an email address, from, sender, reply-to, etc, I have noticed this is how an email address is represented:
(("Name on Email Account" NIL "emailaddress" "domain.com"))
or for accounts with no email name set -
((NIL NIL "emailaddressnoname" "domain.com"))
I can see the 1st value is the name, the 3rd value is the email address name & the 4th value is the domain name - but what is the 2nd value for? I've polled for hundreds of emails from many different IMAP servers and this value is always NIL & I'm afraid that one day it's not going to be NIL and it's going to mess up my parsing code.
In the part of the RFC that defines Envelope structure (https://www.rfc-editor.org/rfc/rfc822) nothing is mentioned about this.
Anybody know what's going on?

From RFC 3501, section 7.4.2 (Fetch Responses), subsection ENVELOPE:
An address structure is a parenthesized list that describes an
electronic mail address. The fields of an address structure
are in the following order: personal name, [SMTP]
at-domain-list (source route), mailbox name, and host name.
The second portion represents source routes, which are obsolete on the Internet, so can be effectively ignored.
There is also information about group list syntax, which is also nearly obsolete, but you may come across it occasionally.

Related

How many email addresses can be in a SOA DNS record?

For example, I want to add two or more email addresses to SOA - hostmaster.domain.com and johndoe.gmail.com
If it is possible, how should it look like?
Also, can such email addresses in SOA like hostmaster#domain.com, or hostmaster.domain.com.johndoe.gmail.com break the DNS zone?
It is not possible, you can have only one email address encoded in a SOA record.
As for the second part, I do not know what you mean by "break the zone".
You need to have a valid SOA record, which means among other things changing the # for a . to encode the email address.

How can the email addresses be case sensitive for AWS SES alone?

I am planning to use Amazon SES to send email. But this page says email addresses are case sensitive. How can it be case sensitive when email providers like Google and Yahoo are not case-sensitive. Gmail doesn't differentiate a123456#gmail.com vs. A123456#GMAIL.COM. It still sends to same single owner of that email address. Though I identify users as unique using their email addresses by saving in database, this sounds fishy.
Any email address will have two parts localmailbox#domain.com.
domain.com: This is your domain name and this part will always be case insensitive
localmailbox: This part is case sensitive - theoretically different cases would point to different mail boxes. But to avoid confusion email providers like gmail enforce case insensitive mailboxes.
Why amazon has it as case-sensitive - this can be because of the RFC-5321 which states
SMTP implementations MUST take care to preserve the case of mailbox local-parts. In particular, for some hosts, the user "smith" is different from the user "Smith". However, exploiting the case sensitivity of mailbox local-parts impedes interoperability and is discouraged.

How Random email generation and capturing work

I would like to understand how can I capture emails sent to different random email ids generated by server in one inbox to run analysis on those emails something like this website does : https://www.mail-tester.com/
Here , with each page referesh, you would notice a new random email id is generated. If an email is sent to this random email id, the mail-tester server captures that email, assesses it using spamassassin and generates a report. I want to understand how can we capture emails sent to so many different random email ids in a single inbox so that they can be assessed by spamassassin or any other utility.
Practial implementation for unix/linux sendmail using procmail as its local mailer.
Use FEATURE(virtusertable) to redirect messages for xyz#test.example.net to user+xyz (user user with +xyz "detail").
~user/.procmailrc will process incoming messages upon delivery. xyz (+detail) will be available via $1.
See also: Sendmail-FAQ-3.29: How can I add a header specifying the actual recipient when having multiple users in a virtual domain go to a single mailbox?

Can you order attachments in an e-mail so that the receiver receives them in the same order?

We're considering using an external application to send e-mails where the attachments have huge filesizes.
One of our users states the requirement: it must be possible to ORDER attachments, so that I can refer to them as "the first attachment", "the second attachment" and the receiver will see the attachments in the same order I sent them.
She claims any normal email clients support this: the sender chooses the order, the recipients client always shows the attachments in this order.
I can't verify that claim. Is this true? Is it stated anywhere? How (technically) are attachments ordered?
Well... Inside the message there is order. Attachments are sent sequentially one-after-the-other inside MIME text. But RFC makes no statement on how these should be displayed in email client. And it even might depend on your email generating software to keep the order you added the attachments in (JavaMail does so)
Things you could consider:
Prefix your attachment filenames with a number 1_first_attachment.txt 2_contract.pdf and so on.
Use HTML for your emails and create a section "attachments: a, b, c" with linkd to the attachments using Content-ID (href="cid:xxx")
Actual, when u load the document to the email, and load next, they gonna be in order anyway. They not gonna be mixed.
if u afraid that particular ur email gonna mix attachments, just add numerical order)
This is example where i just adding files. I just by holding shift click on the files in that order that i wanted and that is all.
And i receive this message with attachments in the same order as it was sent.

Email validation MX Lookup

I have been asked to implement some email address validation on a web app - I'm sure we've all been there a thousand times... however, this time I have been asked to do an MX Lookup on the domain to see if it accepts emails.
Does anyone know of any potential problems with doing this? Is an mx lookup a reliable way of finding out if a domain accepts email? are there any edge cases where a valid email address could fail an MX lookup check?
Thanks for your advice!
are there any edge cases where a valid email address could fail an MX lookup check?
Yes, in that where there is no MX record, MTAs fall back to using the A record instead. So only allowing MX records would fail a class of mail servers that work in the real world.
Allowing any name with an MX or A record at least detects obvious mistypings that result in NXDOMAIN. However it will still allow mistypings that end up at squatter sites. A further step for addresses resolved by A records might be to check where port 25 is accepting connections on that address.
You can only check if there is an mail server registered for the domain.
If the server also accepts mails and if the address is valid (not syntactically but in the sense that there exists a inbox for it and so on...) you will only find out when sending the e.g. registration email
sample on how to do this in PHP
function mailserver_exists($email) {
list($user,$domain) = split('#',$email);
//included check for 'A' after [comment from bobince][1]
return checkdnsrr($domain,'MX') || checkdnsrr($domain,'A');
}
if(domain_exists('joe#foreigndomain.xx')) {...} else {...}
Yes you can use 'TinyTim#192.184.165.13' too. The PHP documentation for checkdnsrr(host, type) states
host may either be the IP address in
dotted-quad notation or the host name