---
title: "Determine if an Email address is Gmail or Hosted Gmail (Google Apps for Your Domain)"
description: "<p>For my latest venture, <a href="http://www.myfamilio.com">MyFamilio</a>, I needed to know if a user’s Email address is a Gmail one so that I could show the user his/her contacts from Gmail.</p>
<p>Figuring out if the user is on Gmail is usually easy – the Email ends with @gmail.com. But what happens for all of those Google Apps for Your domain (like my own, which uses the @sandler.co.il domain) ?</p>
<p>Well, you can easily detect that by running a DNS query on the MX record.</p>"
doc_version: "1"
last_updated: "2017-06-02"
date: 2011-07-17
tags: [Code, dnspython, Gmail, google-apps-for-your-domain, Python]
canonical: "https://eran.sandler.co.il/2011/07/17/determine-if-an-email-address-is-gmail-or-hosted-gmail-google-apps-for-your-domain/"
---

## Sitemap

- [Home](https://eran.sandler.co.il/)

For my latest venture, [MyFamilio][1], I needed to know if a user&#8217;s Email address is a Gmail one so that I could show the user his/her contacts from Gmail.

Figuring out if the user is on Gmail is usually easy &#8211; the Email ends with @gmail.com. But what happens for all of those Google Apps for Your domain (like my own, which uses the @sandler.co.il domain) ?

Well, you can easily detect that by running a DNS query on the MX record.

I wrote a small function in Python which uses dnspyhon to do just that, determine if an Email address is hosted on Gmail or not.

[Check the gist here][2].



[Check the gist here][2].

 [1]: http://www.myfamilio.com
 [2]: https://gist.github.com/1087324