Skip to content

Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.

feat: Detect role-based accounts (#348)

Amaury Martiny7c612fda1107
diff --git a/README.md b/README.md
index a490074b..aaccc9bb 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ This software is licensed under the GPL-3.0 license, which forbids it being inte
| ✅ | **Mailbox disabled** | Has this email address been disabled by the email provider? | `smtp.is_disabled` |
| ✅ | **Full inbox** | Is the inbox of this mailbox full? | `smtp.has_full_inbox` |
| ✅ | **Catch-all address** | Is this email address a [catch-all](https://debounce.io/blog/help/what-is-a-catch-all-or-accept-all/) address? | `smtp.is_catch_all` |
-| 🔜 | **Role account validation** | Is the email address a well-known role account? | [Issue #88](https://github.com/amaurymartiny/check-if-email-exists/issues/88) |
+| ✅ | **Role account validation** | Is the email address a well-known role account? | `misc.is_role_account` |
| 🔜 | **Free email provider check** | Is the email address bound to a known free email provider? | [Issue #89](https://github.com/amaurymartiny/check-if-email-exists/issues/89) |
| 🔜 | **Syntax validation, provider-specific** | According to the syntactic rules of the target mail provider, is the address syntactically valid? | [Issue #90](https://github.com/amaurymartiny/check-if-email-exists/issues/90) |
| 🔜 | **Honeypot detection** | Does email address under test hide a [honeypot](https://en.wikipedia.org/wiki/Spamtrap)? | [Issue #91](https://github.com/amaurymartiny/check-if-email-exists/issues/91) |
@@ -174,7 +174,8 @@ The output will be a JSON with the below format, the fields should be self-expla
{
"input": "[email protected]",
"misc": {
- "is_disposable": false
+ "is_disposable": false,
+ "is_role_account": false
},
"mx": {
"accepts_mail": true,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 66a9a125..6c7bb2e2 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -134,13 +134,7 @@ async fn check_single_email(input: CheckEmailInput) -> CheckEmailOutput {
};
}
- let my_misc = check_misc(
- &my_syntax
- .address
- .as_ref()
- .expect("We already checked that the email has valid format. qed.")
- .as_ref(),
- );
+ let my_misc = check_misc(&my_syntax);
debug!(
target: LOG_TARGET,
"Found the following misc details: {:?}", my_misc
diff --git a/core/src/misc.rs b/core/src/misc.rs
index 27e186e6..aff12132 100644
--- a/core/src/misc.rs
+++ b/core/src/misc.rs
@@ -14,19 +14,25 @@
// You should have received a copy of the GNU General Public License
// along with check-if-email-exists. If not, see <http://www.gnu.org/licenses/>.
+use super::syntax::SyntaxDetails;
use serde::Serialize;
-/// Details that we gathered from connecting to this email via SMTP.
+const ROLE_ACCOUNTS: &str = include_str!("./util/roles.json");
+
+/// Miscelleanous details about the email address.
#[derive(Debug, Serialize)]
pub struct MiscDetails {
/// Is this a DEA (disposable email account)?
pub is_disposable: bool,
+ /// Is this email a role-based account?
+ pub is_role_account: bool,
}
impl Default for MiscDetails {
fn default() -> Self {
MiscDetails {
is_disposable: false,
+ is_role_account: false,
}
}
}
@@ -39,11 +45,22 @@ impl Default for MiscDetails {
pub enum MiscError {}
/// Fetch misc details about the email address, such as whether it's disposable.
-pub fn check_misc(address: &str) -> MiscDetails {
+pub fn check_misc(syntax: &SyntaxDetails) -> MiscDetails {
+ let role_accounts: Vec<&str> =
+ serde_json::from_str(ROLE_ACCOUNTS).expect("roles.json is a valid json. qed.");
+
MiscDetails {
// mailchecker::is_valid checks also if the syntax is valid. But if
// we're here, it means we're sure the syntax is valid, so is_valid
// actually will only check if it's disposable.
- is_disposable: !mailchecker::is_valid(address),
+ is_disposable: !mailchecker::is_valid(
+ syntax
+ .address
+ .as_ref()
+ .expect("We already checked that the syntax was valid. qed.")
+ .to_string()
+ .as_ref(),
+ ),
+ is_role_account: role_accounts.contains(&syntax.username.to_lowercase().as_ref()),
}
}
diff --git a/core/src/smtp.rs b/core/src/smtp.rs
index 2abc5cd1..30e5aec6 100644
--- a/core/src/smtp.rs
+++ b/core/src/smtp.rs
@@ -192,7 +192,6 @@ async fn email_deliverable(
// Check if the email account has been disabled or blocked.
// 554 The email account that you tried to reach is disabled. Learn more at https://support.google.com/mail/?p=DisabledUser"
if err_string.contains("disabled")
- || err_string.contains("blocked")
// 554 delivery error: Sorry your message to [email] cannot be delivered. This account has been disabled or discontinued
|| err_string.contains("discontinued")
{
diff --git a/core/src/util/roles.json b/core/src/util/roles.json
new file mode 100644
index 00000000..9cd8227a
--- /dev/null
+++ b/core/src/util/roles.json
@@ -0,0 +1,891 @@
+[
+ "2015",
+ "2016",
+ "2017",
+ "2018",
+ "2019",
+ "2020",
+ "abuse",
+ "academy",
+ "accessibility",
+ "account",
+ "accountant",
+ "accounting",
+ "accountmanager",
+ "accountmanagers",
+ "accounts",
+ "accountspayable",
+ "acquisition",
+ "admin",
+ "admin1",
+ "administracao",
+ "administracion",
+ "administrador",
+ "administratie",
+ "administratif",
+ "administration",
+ "administrativo",
+ "administrator",
+ "administrators",
+ "admins",
+ "adminteam",
+ "admissions",
+ "adops",
+ "ads",
+ "adventure",
+ "advertise",
+ "advertising",
+ "advertisingsales",
+ "advice",
+ "advisor",
+ "advisors",
+ "adwords",
+ "affiliate",
+ "affiliates",
+ "agence",
+ "agencia",
+ "agency",
+ "agents",
+ "alarm",
+ "alarms",
+ "alert",
+ "alerts",
+ "alexa",
+ "all",
+ "all-employees",
+ "all-pms",
+ "all-staff",
+ "all-team",
+ "all-users",
+ "all.employees",
+ "all.staff",
+ "all.users",
+ "all_staff",
+ "alla",
+ "alle",
+ "allemployees",
+ "allhands",
+ "allsales",
+ "allstaff",
+ "allstudents",
+ "allteachers",
+ "allteam",
+ "allusers",
+ "alpha",
+ "alphas",
+ "alumni",
+ "ambassadors",
+ "amministrazione",
+ "analysts",
+ "analytics",
+ "android",
+ "angels",
+ "animation",
+ "announce",
+ "announcements",
+ "ap",
+ "api",
+ "app",
+ "apple",
+ "application",
+ "applications",
+ "apply",
+ "appointments",
+ "apps",
+ "archives",
+ "asistente",
+ "asset",
+ "assistanthead",
+ "assistencia",
+ "assistenza",
+ "associates",
+ "associates-all",
+ "ateam",
+ "atencionalcliente",
+ "atendimento",
+ "auctions",
+ "available",
+ "backend",
+ "backend-dev",
+ "backup",
+ "bd",
+ "benefits",
+ "berlin",
+ "bestellung",
+ "beta",
+ "biblioteca",
+ "bibliotheque",
+ "billing",
+ "bills",
+ "biuro",
+ "biz",
+ "bizdev",
+ "blog",
+ "board",
+ "bod",
+ "bookclub",
+ "booking",
+ "bookings",
+ "boston",
+ "boxoffice",
+ "brand",
+ "branding",
+ "brands",
+ "brandsolutions",
+ "broadcast",
+ "buchhaltung",
+ "bugs",
+ "build",
+ "bursar",
+ "busdev",
+ "business",
+ "business_team",
+ "businessdevelopment",
+ "ca",
+ "caltrain",
+ "campaign",
+ "campaigns",
+ "campusteam",
+ "capacitacion",
+ "captain",
+ "captains",
+ "care",
+ "career",
+ "careers",
+ "catering",
+ "central",
+ "centro",
+ "ceo",
+ "ceos",
+ "channel-sales",
+ "chat",
+ "chatter",
+ "chef",
+ "chicago",
+ "china",
+ "citymanagers",
+ "classof2016",
+ "classof2017",
+ "classof2018",
+ "classof2019",
+ "classroom_teachers",
+ "client",
+ "clientes",
+ "clients",
+ "clientservices",
+ "clinic",
+ "cloud",
+ "cm",
+ "co-op",
+ "coach",
+ "coaches",
+ "coaching",
+ "code",
+ "colaboradores",
+ "colegio",
+ "com",
+ "comenzi",
+ "comercial",
+ "comercial1",
+ "comercial2",
+ "comments",
+ "commercial",
+ "commerciale",
+ "commissions",
+ "committee",
+ "comms",
+ "communication",
+ "communications",
+ "community",
+ "community",
+ "company",
+ "company.wide",
+ "compete",
+ "competition",
+ "compliance",
+ "compras",
+ "compta",
+ "comptabilite",
+ "comunicacao",
+ "comunicacion",
+ "comunicaciones",
+ "comunicazione",
+ "concierge",
+ "conference",
+ "connect",
+ "consultant",
+ "consultas",
+ "consulting",
+ "consultoria",
+ "contabil",
+ "contabilidad",
+ "contabilidade",
+ "contabilita",
+ "contact",
+ "contactenos",
+ "contacto",
+ "contactus",
+ "contador",
+ "contato",
+ "content",
+ "contractor",
+ "contractors",
+ "contracts",
+ "controller",
+ "coordinator",
+ "copyright",
+ "core",
+ "coreteam",
+ "corp",
+ "corporate",
+ "corporatesales",
+ "council",
+ "courrier",
+ "creative",
+ "crew",
+ "crm",
+ "cs",
+ "csm",
+ "csteam",
+ "cultura",
+ "culture",
+ "customer",
+ "customer.service",
+ "customercare",
+ "customerfeedback",
+ "customers",
+ "customerservice",
+ "customerservicecenter",
+ "customerservices",
+ "customersuccess",
+ "customersupport",
+ "custserv",
+ "daemon",
+ "data",
+ "database",
+ "deals",
+ "dean",
+ "delivery",
+ "demo",
+ "denver",
+ "departures",
+ "deploy",
+ "deputy",
+ "deputyhead",
+ "design",
+ "designer",
+ "designers",
+ "dev",
+ "developer",
+ "developers",
+ "development",
+ "devnull",
+ "devops",
+ "devs",
+ "devteam",
+ "digital",
+ "digsitesvalue",
+ "direccion",
+ "direction",
+ "director",
+ "directors",
+ "directory",
+ "diretoria",
+ "direzione",
+ "discuss",
+ "dispatch",
+ "diversity",
+ "dns",
+ "docs",
+ "domain",
+ "domainmanagement",
+ "domains",
+ "donations",
+ "donors",
+ "download",
+ "dreamteam",
+ "ecommerce",
+ "editor",
+ "editorial",
+ "editors",
+ "education",
+ "einkauf",
+ "email",
+ "emergency",
+ "employee",
+ "employees",
+ "employment",
+ "eng",
+ "eng-all",
+ "engagement",
+ "engineering",
+ "engineers",
+ "english",
+ "enq",
+ "enquire",
+ "enquires",
+ "enquiries",
+ "enquiry",
+ "enrollment",
+ "enterprise",
+ "equipe",
+ "equipo",
+ "error",
+ "errors",
+ "escritorio",
+ "europe",
+ "event",
+ "events",
+ "everybody",
+ "everyone",
+ "exec",
+ "execs",
+ "execteam",
+ "executive",
+ "executives",
+ "expenses",
+ "expert",
+ "experts",
+ "export",
+ "facilities",
+ "facturacion",
+ "faculty",
+ "family",
+ "farmacia",
+ "faturamento",
+ "fax",
+ "fbl",
+ "feedback",
+ "fellows",
+ "finance",
+ "financeiro",
+ "financeiro2",
+ "finanzas",
+ "firmapost",
+ "fiscal",
+ "food",
+ "football",
+ "founders",
+ "france",
+ "franchise",
+ "friends",
+ "frontdesk",
+ "frontend",
+ "frontoffice",
+ "fte",
+ "ftp",
+ "fulltime",
+ "fun",
+ "fundraising",
+ "gardner",
+ "geeks",
+ "general",
+ "geral",
+ "giving",
+ "global",
+ "grants",
+ "graphics",
+ "group",
+ "growth",
+ "hackathon",
+ "hackers",
+ "head",
+ "head.office",
+ "headoffice",
+ "heads",
+ "headteacher",
+ "hello",
+ "help",
+ "helpdesk",
+ "hi",
+ "highschool",
+ "hiring",
+ "hola",
+ "home",
+ "homes",
+ "hosting",
+ "hostmaster",
+ "hotel",
+ "house",
+ "hq",
+ "hr",
+ "hrdept",
+ "hsstaff",
+ "hsteachers",
+ "humanresources",
+ "ideas",
+ "implementation",
+ "import",
+ "inbound",
+ "inbox",
+ "india",
+ "info",
+ "infor",
+ "informacion",
+ "informatica",
+ "information",
+ "informatique",
+ "informativo",
+ "infra",
+ "infrastructure",
+ "ingenieria",
+ "innovation",
+ "inoc",
+ "inquiries",
+ "inquiry",
+ "insidesales",
+ "insights",
+ "instagram",
+ "insurance",
+ "integration",
+ "integrations",
+ "intern",
+ "internal",
+ "international",
+ "internet",
+ "interns",
+ "internship",
+ "invest",
+ "investment",
+ "investor",
+ "investorrelations",
+ "investors",
+ "invoice",
+ "invoices",
+ "invoicing",
+ "ios",
+ "iphone",
+ "ir",
+ "ispfeedback",
+ "ispsupport",
+ "it",
+ "ithelp",
+ "itsupport",
+ "itunes",
+ "jira",
+ "job",
+ "jobs",
+ "join",
+ "jornalismo",
+ "junk",
+ "kontakt",
+ "kundeservice",
+ "la",
+ "lab",
+ "laboratorio",
+ "labs",
+ "ladies",
+ "latam",
+ "launch",
+ "lead",
+ "leaders",
+ "leadership",
+ "leadership-team",
+ "leadershipteam",
+ "leads",
+ "leasing",
+ "legal",
+ "letters",
+ "library",
+ "licensing",
+ "links",
+ "list",
+ "list-request",
+ "login",
+ "logistica",
+ "logistics",
+ "logistiek",
+ "lt",
+ "lunch",
+ "mail",
+ "mailbox",
+ "maildaemon",
+ "mailer-daemon",
+ "mailerdaemon",
+ "mailing",
+ "maintenance",
+ "management",
+ "management-group",
+ "management.team",
+ "management_team",
+ "manager",
+ "managers",
+ "marketing",
+ "marketing-ops",
+ "marketing-team",
+ "marketingteam",
+ "marketplace",
+ "master",
+ "mayor",
+ "md",
+ "media",
+ "meetup",
+ "member",
+ "members",
+ "membership",
+ "mentors",
+ "metrics",
+ "mgmt",
+ "middleschool",
+ "misc",
+ "mkt",
+ "mktg",
+ "mobile",
+ "monitor",
+ "monitoring",
+ "montreal",
+ "msstaff",
+ "msteachers",
+ "mt",
+ "music",
+ "network",
+ "newbiz",
+ "newbusiness",
+ "news",
+ "newsletter",
+ "newyork",
+ "nntp",
+ "no-reply",
+ "no.replay",
+ "no.reply",
+ "nobody",
+ "noc",
+ "none",
+ "noreply",
+ "noresponse",
+ "northamerica",
+ "nospam",
+ "notes",
+ "notifications",
+ "notify",
+ "nps",
+ "null",
+ "ny",
+ "nyc",
+ "nyoffice",
+ "offboarding",
+ "offers",
+ "office",
+ "officeadmin",
+ "officemanager",
+ "officers",
+ "officestaff",
+ "offtopic",
+ "oficina",
+ "onboarding",
+ "online",
+ "onsite",
+ "ooo",
+ "operaciones",
+ "operations",
+ "ops",
+ "order",
+ "orders",
+ "ordini",
+ "outage",
+ "outreach",
+ "owners",
+ "parents",
+ "paris",
+ "partner",
+ "partners",
+ "partnerships",
+ "parts",
+ "pay",
+ "payment",
+ "payments",
+ "paypal",
+ "payroll",
+ "pd",
+ "people",
+ "peoplemanagers",
+ "peopleops",
+ "performance",
+ "personnel",
+ "phish",
+ "phishing",
+ "photos",
+ "planning",
+ "platform",
+ "pm",
+ "portfolio",
+ "post",
+ "postbox",
+ "postfix",
+ "postmaster",
+ "ppc",
+ "pr",
+ "prefeitura",
+ "presales",
+ "presidencia",
+ "president",
+ "presidente",
+ "press",
+ "presse",
+ "prime",
+ "principal",
+ "principals",
+ "privacy",
+ "procurement",
+ "prod",
+ "produccion",
+ "product",
+ "product-team",
+ "product.growth",
+ "product.management",
+ "product.managers",
+ "product.team",
+ "production",
+ "productmanagers",
+ "products",
+ "productteam",
+ "produto",
+ "program",
+ "programs",
+ "project",
+ "projectmanagers",
+ "projects",
+ "promo",
+ "promotions",
+ "protocollo",
+ "proveedores",
+ "publicidade",
+ "publisher",
+ "publishers",
+ "purchase",
+ "purchases",
+ "purchasing",
+ "qa",
+ "qualidade",
+ "questions",
+ "quotes",
+ "random",
+ "realestate",
+ "receipts",
+ "recepcion",
+ "reception",
+ "receptionist",
+ "recruit",
+ "recruiter",
+ "recruiters",
+ "recruiting",
+ "recruitment",
+ "recrutement",
+ "recursoshumanos",
+ "redacao",
+ "redaccion",
+ "redaction",
+ "redazione",
+ "referrals",
+ "register",
+ "registrar",
+ "registration",
+ "relacionamento",
+ "release",
+ "releases",
+ "remote",
+ "remove",
+ "rentals",
+ "report",
+ "reporting",
+ "reports",
+ "request",
+ "requests",
+ "research",
+ "reservaciones",
+ "reservas",
+ "reservation",
+ "reservations",
+ "residents",
+ "response",
+ "restaurant",
+ "resume",
+ "resumes",
+ "retail",
+ "returns",
+ "revenue",
+ "rezervari",
+ "rfp",
+ "rnd",
+ "rockstars",
+ "root",
+ "rrhh",
+ "rsvp",
+ "sales",
+ "sales-team",
+ "sales.team",
+ "sales1",
+ "sales2",
+ "salesengineers",
+ "salesforce",
+ "salesops",
+ "salesteam",
+ "sanfrancisco",
+ "school",
+ "schooloffice",
+ "science",
+ "sdr",
+ "se",
+ "search",
+ "seattle",
+ "secretaria",
+ "secretariaat",
+ "secretaris",
+ "secretary",
+ "security",
+ "sekretariat",
+ "sem",
+ "seniors",
+ "seo",
+ "server",
+ "service",
+ "serviceclient",
+ "servicedesk",
+ "services",
+ "servicioalcliente",
+ "sf",
+ "sf-office",
+ "sfo",
+ "sfoffice",
+ "sfteam",
+ "shareholders",
+ "shipping",
+ "shop",
+ "shopify",
+ "shopping",
+ "signup",
+ "signups",
+ "singapore",
+ "sistemas",
+ "site",
+ "smtp",
+ "social",
+ "socialclub",
+ "socialmedia",
+ "socios",
+ "software",
+ "solutions",
+ "soporte",
+ "sos",
+ "spam",
+ "sponsorship",
+ "sport",
+ "squad",
+ "staff",
+ "startups",
+ "stats",
+ "stockholm",
+ "store",
+ "stories",
+ "strategy",
+ "stripe",
+ "student",
+ "students",
+ "studio",
+ "submissions",
+ "submit",
+ "subscribe",
+ "subscriptions",
+ "success",
+ "suggestions",
+ "supervisor",
+ "supervisors",
+ "suporte",
+ "supply",
+ "support",
+ "support-team",
+ "supportteam",
+ "suprimentos",
+ "sydney",
+ "sysadmin",
+ "system",
+ "systems",
+ "ta",
+ "talent",
+ "tax",
+ "teachers",
+ "team",
+ "teamleaders",
+ "teamleads",
+ "tech",
+ "technical",
+ "technik",
+ "technology",
+ "techops",
+ "techsupport",
+ "techteam",
+ "tecnologia",
+ "tesoreria",
+ "test",
+ "testgroup",
+ "testing",
+ "the.principal",
+ "theoffice",
+ "theteam",
+ "tickets",
+ "time",
+ "timesheets",
+ "todos",
+ "tools",
+ "tour",
+ "trade",
+ "trainers",
+ "training",
+ "transport",
+ "travel",
+ "treasurer",
+ "tribe",
+ "trustees",
+ "turismo",
+ "twitter",
+ "uk",
+ "undisclosed-recipients",
+ "unsubscribe",
+ "update",
+ "updates",
+ "us",
+ "usa",
+ "usenet",
+ "user",
+ "users",
+ "usteam",
+ "uucp",
+ "ux",
+ "vendas",
+ "vendas1",
+ "vendas2",
+ "vendor",
+ "vendors",
+ "ventas",
+ "ventas1",
+ "ventas2",
+ "verkauf",
+ "verwaltung",
+ "video",
+ "vip",
+ "voicemail",
+ "volunteer",
+ "volunteering",
+ "volunteers",
+ "vorstand",
+ "warehouse",
+ "watercooler",
+ "web",
+ "webadmin",
+ "webdesign",
+ "webdev",
+ "webinars",
+ "webmaster",
+ "website",
+ "webteam",
+ "welcome",
+ "whois",
+ "wholesale",
+ "women",
+ "wordpress",
+ "work",
+ "workshop",
+ "writers",
+ "www",
+ "zentrale"
+]
diff --git a/test_suite/src/fixtures/foo.json b/test_suite/src/fixtures/foo.json
index aa2e664a..55236e0e 100644
--- a/test_suite/src/fixtures/foo.json
+++ b/test_suite/src/fixtures/foo.json
@@ -1,6 +1,6 @@
{
"input": "foo",
- "misc": { "is_disposable": false },
+ "misc": { "is_disposable": false, "is_role_account": false },
"mx": { "accepts_mail": false, "records": [] },
"smtp": {
"can_connect_smtp": false,
diff --git a/test_suite/src/fixtures/[email protected] b/test_suite/src/fixtures/[email protected]
index 013cbe12..e0ad0653 100644
--- a/test_suite/src/fixtures/[email protected]
+++ b/test_suite/src/fixtures/[email protected]
@@ -1,6 +1,6 @@
{
"input": "[email protected]",
- "misc": { "is_disposable": false },
+ "misc": { "is_disposable": false, "is_role_account": false },
"mx": { "accepts_mail": false, "records": [] },
"smtp": {
"can_connect_smtp": false,
diff --git a/test_suite/src/fixtures/[email protected] b/test_suite/src/fixtures/[email protected]
index 764d0b05..4dbc1174 100644
--- a/test_suite/src/fixtures/[email protected]
+++ b/test_suite/src/fixtures/[email protected]
@@ -1,6 +1,6 @@
{
"input": "foo@bar",
- "misc": { "is_disposable": false },
+ "misc": { "is_disposable": false, "is_role_account": false },
"mx": { "accepts_mail": false, "records": [] },
"smtp": {
"can_connect_smtp": false,
diff --git a/test_suite/src/fixtures/[email protected] b/test_suite/src/fixtures/[email protected]
index 5eaa7e85..00035fbd 100644
--- a/test_suite/src/fixtures/[email protected]
+++ b/test_suite/src/fixtures/[email protected]
@@ -1,6 +1,6 @@
{
"input": "[email protected]",
- "misc": { "is_disposable": false },
+ "misc": { "is_disposable": false, "is_role_account": false },
"mx": {
"accepts_mail": true,
"records": [