By provider, I mean the provider responsible for mail, e.g. for gmail
the provider would be gmail
(or/by google) and for microsoft.com
it would be outlook
(by microsoft).
Basically, I want to find out given an email domain e.g. abc@xyz.com
, hxy@tuv.com
is from a specific provider(outlook or gmail) in our case, since xyz
or tuv
is not explicitly evident which provider it belongs to.
I have succeded somewhat, my idea being to make use of MX
records, so I do something like this in nodejs:
const dnsMod = require('dns');
dnsMod.resolveMx(
'mydomain.com', (err, value)=>{
console.log('The error is : ', err);
console.log('The value is : ', value);
}
)
and it returns records like this:
[
{ exchange: 'alt3.gmail-smtp-in.l.google.com', priority: 30 },
{ exchange: 'alt1.gmail-smtp-in.l.google.com', priority: 10 },
{ exchange: 'gmail-smtp-in.l.google.com', priority: 5 },
{ exchange: 'alt2.gmail-smtp-in.l.google.com', priority: 20 },
{ exchange: 'alt4.gmail-smtp-in.l.google.com', priority: 40 }
]
so, seeing this we can conclude the provider in this case is infact gmail
.
But, my point is, is it safe to conclude the provider is gmail just it contains words like google
, gmail
etc. In other words, do google's mail servers always have a google.com
in the end, (or Similarly, microsoft's mail provider have outlook.com
or microsoft.com
in the end)? If not, what better way would be to confirm this?
EDIT: As per suggested by comment, I need the information because, based on the information I need to show only one of google or outlook button.