Search code examples
emaildnssmtpgmail

What addresses are exactly, returned by MX lookup?


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?

Solution

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