-10

dig gmail.com returns this:

;; ANSWER SECTION:                                                                                                                                            
gmail.com.              3600    IN      MX      40 alt4.gmail-smtp-in.l.google.com.                                                                           
gmail.com.              3600    IN      MX      30 alt3.gmail-smtp-in.l.google.com.                                                                           
gmail.com.              3600    IN      MX      20 alt2.gmail-smtp-in.l.google.com.                                                                           
gmail.com.              3600    IN      MX      5 gmail-smtp-in.l.google.com.                                                                                 
gmail.com.              3600    IN      MX      10 alt1.gmail-smtp-in.l.google.com.    

How about the smtp.gmail.com, why isn't it included? Is there a way to find it through some utility? Or is it what can found in the documentation of gmail only?

The same question goes for other email services out there.

My initial goal is find all smtp servers of an email provider.

Jodimoro
  • 147
  • 2
  • 9
  • 2
    II think there's a lot of back and forth going on here because we aren't sure what you're looking for exactly. Are you looking for where to route mail to users of gmail.com? Or are you looking for the servers that users of gmail.com should use in order to send e-mail to any domain on the internet? If the former, you should not use `smtp.gmail.com`, and should use the servers listed in the `MX` record. If the latter, it's appropriate to use `smtp.google.com`, and you learn of that record's existence through the `_submission._tcp.gmail.com` query. – Andrew B Jul 02 '17 at 03:36
  • @AndrewB, don't be thinking too much. My question isn't about gmail in particular. – Jodimoro Jul 02 '17 at 03:49
  • gmail isn't the focus of that question at all. I give up. – Andrew B Jul 02 '17 at 03:52
  • @AndrewB, you said - use stmp.gmail.com. I said -- my question isn't about gmail in particular. It's about any email service provider. Namely, "smtp.some_domain.com" won't work in 100% of the cases. – Jodimoro Jul 02 '17 at 04:11
  • 3
    Then you should accept Wesley's answer. – Andrew B Jul 02 '17 at 05:45

3 Answers3

12

How about the smtp.gmail.com, why isn't it included?

Because smtp.gmail.com doesn't receive email for the gmail.com domain. You asked for the MX record for gmail.com. The answer you got was exactly that. The MX record designates which host(s) receives email for a given domain. The MX record tells you nothing about client submission SMTP servers, etc. A host named smtp.example.com need not be the host that receives email for said domain. A host that receives email for a domain could literally be named anything.

If you want to know what host(s) receives email for a given domain then perform an MX record lookup just as you did. If you want to know what host a client of a specific email provider should use to send email, consult the email hoster's documentation.

joeqwerty
  • 109,901
  • 6
  • 81
  • 172
  • **Is there a way to find it through some utility?** – Jodimoro Jul 02 '17 at 03:05
  • What are you trying to find exactly? If you're trying to find the hosts(s) that receive email for a given domain then you've already done that. That's what the MX record is for. – joeqwerty Jul 02 '17 at 03:11
  • I've said: is there a way to find "smtp.gmail.com" via "dig" or an analogue? – Jodimoro Jul 02 '17 at 03:12
  • All that's going to do is find the host (if it exists) named smtp.gmail.com. That tells you nothing about what that host is or what services it may or may not offer. What are you trying to find out? Are you trying to find the host that receives email for a domain? – joeqwerty Jul 02 '17 at 03:14
  • is there a way to find "smtp.gmail.com" via "dig" or an analogue? – Jodimoro Jul 02 '17 at 03:16
  • `What are you trying to find out?` -- an smtp server. – Jodimoro Jul 02 '17 at 03:20
  • `find an smtp server.` - A server that accepts email for a given domain (as designated via the MX record) is an SMTP server. A server that accepts client connections for email submission is an SMTP server. But they're not necessarily the same server. I don't understand what you're trying to accomplish by "finding" an SMTP server. You need to be more specific. Are you trying to find the SMTP server that accepts email for a given domain or are you trying to find the SMTP server used for client submission? – joeqwerty Jul 02 '17 at 03:24
  • Okay, how can I find the 1st one and 2nd one? – Jodimoro Jul 02 '17 at 03:27
  • You don't know, and it's what you should've pointed out from the beginning. – Jodimoro Jul 02 '17 at 03:50
  • 4
    I don't know what? I don't know what you're after? You're right. You haven't sufficiently explained the context of your quest to "find an SMTP server." Are you looking for the SMTP server that accepts email for a given domain? Are you trying to find the client submission SMTP server for email clients? We don't know and we've tried to figure that out by asking you a number of questions, but you've gone and turned into a jerk and have taken a rude turn with your comments. Good luck in your quest to "find the SMTP server." – joeqwerty Jul 02 '17 at 03:59
  • `Okay, how can I find the 1st one and 2nd one?` – Jodimoro Jul 02 '17 at 04:09
  • `Good luck in your quest to "find the SMTP server."` -- thank you! I'll need luck. – Jodimoro Jul 02 '17 at 05:00
9

As joeqwerty rightly points out, it doesn't show smtp.google.com because a MX record indicates where mail servers should send messages destined for that domain. This is not the same as the servers that should be used by an end-user's e-mail client to transmit outgoing messages to arbitrary destinations.

RFC 6186 describes a method for automatically detecting a SMTP server with SRV records. The problem is that for the majority of the internet's life, SMTP server settings have been conveyed through documentation and not through DNS. You can't rely on this information being present. Modern e-mail clients will attempt to automatically detect the SMTP server settings based on the domain suffix you provided, but if that fails the user has to rely on that company's documentation as usual. This information is not otherwise available, electronically or otherwise.

submission: Identifies an MSA using [RFC4409]. Note that this covers connections both with and without Transport Layer Security (TLS) [RFC5246] as defined for SMTP in [RFC3207].

Example: service record

   _submission._tcp     SRV 0 1 587 mail.example.com.

In this particular case, the query you needed was _submission._tcp.gmail.com with a type of SRV.

$ dig _submission._tcp.gmail.com SRV


; <<>> DiG 9.9.5-9+deb8u10-Debian <<>> _submission._tcp.gmail.com SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8996
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;_submission._tcp.gmail.com.    IN      SRV

;; ANSWER SECTION:
_submission._tcp.gmail.com. 86400 IN    SRV     5 0 587 smtp.gmail.com.

;; Query time: 9 msec
;; SERVER: 66.228.62.5#53(66.228.62.5)
;; WHEN: Sun Jul 02 03:17:11 UTC 2017
;; MSG SIZE  rcvd: 89
Andrew B
  • 32,588
  • 12
  • 93
  • 131
  • where did you get `_submission._tcp.gmail.com`? – Jodimoro Jul 02 '17 at 03:21
  • 1
    I applied the logic described by the RFC. Read [section 3.1](https://tools.ietf.org/html/rfc6186#section-3.1), followed by [section 4](https://tools.ietf.org/html/rfc6186#section-4). `_submission._tcp` is the prefix applied to the domain. – Andrew B Jul 02 '17 at 03:23
  • It's happened to be correct, yes. But I mean, given a domain name -- gmail.com --- how one can find out what its SRV record(s) is? Without having to check out their website and documentation. – Jodimoro Jul 02 '17 at 03:25
  • If the question is "how can I get a complete list of all SRV records defined by this domain?", the answer is that you can't get such a list. You simply have to ask for them and see if they exist. RFC 6186 describes the standard for how to name the SRV record intended for this specific purpose. It's up to the domain owners to decide whether or not they want to put it into practice. – Andrew B Jul 02 '17 at 03:28
9

My initial goal is find all smtp servers of an email provider.

You can't.

Wesley
  • 32,690
  • 9
  • 82
  • 117