1

While searching for a way to send an email from Python code, I have stumbled upon the following:
when I am doing an MX lookup with host -t mx gmail.com command (which I've "borrowed" from this answer), I am getting the following:

gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.

Non of this servers are mentioned in the official gmail docs (the ones that are there: smtp-relay.gmail.com, smtp.gmail.com, aspmx.l.google.com). My understanding was that MX lookup should return address of the server (or list of them), which is responsible for handling mails for the domain.

My questions are:

  1. Why none of the smtps mentioned in the docs are returned by MX lookup?
  2. Which servers exactly are returned by MX lookup?
  3. Can servers returned by MX lookup be used to send an email to the domain emails (gmail in this case)?
  4. Can servers returned by MX lookup be used to send an email to an arbitrary domain email?
  5. If answer is "yes", to any of two previous questions — what authentication is required to use these servers?
  • 1
    I think the core of your problem is that you mix MTA (Mail Transport Agent) and MSA (Mail Submission Agent). If anyone in the world needs to send an email to someone@gmail.com it needs to find out which MTAs receive emails for this specific domain. Hence the MX lookup and the connection to the returned names. If **a client** of provider gmail.com wants to send an email to anyone (client or not), it needs to find the **MSA** of the provider, that is where to send the message. This is not discovered by MX records, but is in the documentation you linked. Sometimes MTA = MSA, but not at big hosts. – Patrick Mevzek Apr 26 '19 at 17:31
  • @PatrickMevzek, thanks for clear outlining of the essence of my misunderstanding. –  Apr 29 '19 at 07:56

1 Answers1

2

In somewhat laymen's terms:

1. A mail exchanger record (MX record) specifies the mail server responsible for accepting email messages on behalf of a domain name. The mentioned doc page is about using G Suite to send email.

2. See 1, Those are Google servers which receive email destined to gmail.

3. and 4. Sometimes (or maybe even very often), the same server(s) are responsible both for both sending emails out, and receiving emails for the domain. The bigger the email provider, I guess the bigger the chance that those roles are separated. So, other domain's email servers will use servers returned by MX lookup to send emails to gmail, but one (as gmail user) can't use them to send emails to other domains.

5. For the "yes" part, no authentication is needed (you don't need any gmail credentials in order to send email to @gmail user)

Dusan Bajic
  • 10,249
  • 3
  • 33
  • 43
  • Such a *laymen's* terms was, exactly, what I was looking for! Thanks a lot! –  Apr 29 '19 at 06:18