{"id":18981331,"url":"https://github.com/gh0stwizard/libeav","last_synced_at":"2025-04-19T19:34:46.894Z","repository":{"id":83269392,"uuid":"88855297","full_name":"gh0stwizard/libeav","owner":"gh0stwizard","description":"The Email Address Validation Library","archived":false,"fork":false,"pushed_at":"2023-07-08T09:21:57.000Z","size":760,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T17:26:47.192Z","etag":null,"topics":["email-validation","rfc-5321","rfc-5322","rfc-6531","rfc-822"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gh0stwizard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-04-20T10:54:24.000Z","updated_at":"2022-11-02T09:04:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"eabe1665-f135-4859-af5b-a480453852bd","html_url":"https://github.com/gh0stwizard/libeav","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh0stwizard%2Flibeav","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh0stwizard%2Flibeav/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh0stwizard%2Flibeav/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gh0stwizard%2Flibeav/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gh0stwizard","download_url":"https://codeload.github.com/gh0stwizard/libeav/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249780583,"owners_count":21324583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email-validation","rfc-5321","rfc-5322","rfc-6531","rfc-822"],"created_at":"2024-11-08T16:09:33.989Z","updated_at":"2025-04-19T19:34:46.883Z","avatar_url":"https://github.com/gh0stwizard.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libeav - Email Address Validation Library\n\n![build](https://github.com/gh0stwizard/libeav/workflows/build/badge.svg)\n[![codecov](https://codecov.io/gh/gh0stwizard/libeav/branch/master/graph/badge.svg?token=AX694KORHH)](https://codecov.io/gh/gh0stwizard/libeav)\n\n## Description\n\nThis is a library which validates an [Email Address][1]. I do my best to\nsupport all existing RFCs:\n\n* [RFC 822][2]\n* [RFC 5321][3]\n* [RFC 5322][4] (updates `\u003catext\u003e` specification)\n* [RFC 6531][5] (UTF-8 support; updates `\u003catext\u003e` specification)\n\n\nA quick note about [RFC 6531][5]: it is possible that the correct implementation\nSHOULD take into account [RFC 20][6] to exclude some characters:\n``# ` { } | ~ ^``. See the [RFC 6531 switches](#rfc-6531-switches) section below.\n\n\n## What it does not\n\nYou have to be NOT mistaken about the definition of [Email Address][1].\nThis software does NOT implement (at the moment, at least) a full support\nof [Address Specification][14].\n\nAll that this software does it is validating of the [Addr-Spec Specification][15].\nSee details below:\n\n\taddress = mailbox / group\n\tmailbox = name-addr / addr-spec\n\taddr-spec = local-part \"@\" domain\n\n\n## Features\n\n* UTF-8 / IDNA2008 support\n* FQDN \u0026 TLD check (configurable)\n* Local-Part \u0026 Domain length check\n\n\n## Dependencies\n\n* [libidn][17] or [libidn2][18] or [idnkit][8]\n\n### Build dependecies\n\nGeneral requirements:\n\n* [GNU make][10]\n* C99 compiler to compile\n\nTo rebuild the documentation and auto-generate TLD database:\n\n* [Perl][19] + [Text::CSV][29]\n\n\n## Thread-safety\n\nThe library SHOULD be thread-safe. Not tested yet.\n\n\n## Documentation\n\nThe documentation may be found either in [docs][16] directory\nor after installing this library via `man` command:\n\n```\n% man libeav\n```\n\n\n## Build\n\n### Automatic\n\nAt the moment the build system looking for IDN libraries using\nnext order:\n\n1. [libidn2][18]\n2. [libidn][17]\n3. [idnkit][8] - see how to configure below\n\n### Build manually with specific IDN library\n\nIn the case when you have installed `libidn2` and `libidn`\nor `idnkit` (i.e. any 2 or more libraries) on the system, but\nyou want to build `libeav` with specific library you have to\ntell about that like it shown below:\n\n```\n% make FORCE_IDN=idn\n% make check FORCE_IDN=idn\n% make install DESTDIR=/path/to/install/dir\n```\n\nThe `FORCE_IDN` option can have the next values\n(self-described, I hope):\n\n* `idn`\n* `idn2`\n* `idnkit`\n\nWhen there is no `libidn2.pc` file on the system (Debian 8,\nfor instance), then you may do this:\n\n```\n% make FORCE_IDN=idn2 DEFS=\"-DHAVE_LIBIDN2\" LIBS=\"-lidn2\"\n```\n\n\n### Build with idnkit\n\nFirst of all, you have to specify the directory where [idnkit][8]\nwas installed. To do this you have two options:\n\n* Export the `IDNKIT_DIR` environment variable as showed below.\n* Manually change paths in Makefiles.\n\nThe library assumes that `idnkit` was installed in `/usr/local`\nby default.\n\nSecondly, if you planning to install the library to non-standard\ndirectory you may change the destination directory by setting\n`DESTDIR` variable manually.\nThe default value of `DESTDIR` is `/usr/local`.\n\n```\n% export INDKIT_DIR=/home/user/local\n% make\n% make check\n% make install DESTDIR=/path/to/install\n```\n\nIf you have `libidn2` or `libidn` installed, then you must\nuse the `FORCE_IDN` option as show above.\n\n### RFC 6531 switches\n\nIt is possible to build the library to follow rules of [RFC 5322][4] and\n[RFC 20][6]. To so, export or define inline the next options:\n\n* `RFC6531_FOLLOW_RFC5322` = ON | OFF (default OFF)\n* `RFC6531_FOLLOW_RFC20` = ON | OFF (default OFF)\n\nFor instance, define the options above inline:\n\n```\n% make clean\n% make check RFC6531_FOLLOW_RFC5322=ON RFC6531_FOLLOW_RFC20=ON\n```\n\nBriefly about the switches and these RFCs:\n\n* **RFC 5322** allows some CONTROL characters in quotes and quoted pairs. When\n`RFC6531_FOLLOW_RFC5322 = OFF`, **libeav** disallows any CONTROL characters\nwithin *local-part* (copy the **RFC 5321** behavior).\n* **RFC 20** simply disallows the next GRAPHIC characters within *local-part*:\n``# ` { } | ~ ^``.\n\nSee the code of [is_6531_local.c][7] file for details.\n\n### Underscores inside of the domain part\n\nAccording to \"2.3.1. Preferred name syntax\" of [RFC 1035][30], a mail domain\nshould satisfy both the rules of the **RFC 1035** and those in [RFC 822][2].\n\nHistorically, many MX servers do allow underscores in the domain part of an\nemail addresses. The libeav is based on the code base of the [postfix][13],\nspecifically, you may check this by looking at the file\n`src/util/valid_hostname.c` of the current **postfix** distribution.\n\nSince **libeav** 1.2.0 the new option was added:\n* `LABELS_ALLOW_UNDERSCORE` = ON | OFF (default OFF)\n\nPass it to the `make` command, for instance:\n```\n% make FORCE_IDN=idn2 LABELS_ALLOW_UNDERSCORE=ON\n```\n\nBefore this, **libeav** had allowed underscores inside of the domain part\nof the email addresses by default.\n\nAlso should be noted that [idnkit][8] prohibits underscores within\nthe domain part of the email addresses. I'm highly recommending using\n`LABELS_ALLOW_UNDERSCORE=OFF` along side with `idnkit`. At the moment,\n**libeav** calls **idnkit** functions to check the domain part\nonly when `RFC6531` mode is on.\n\n### Updating TLD database\n\nFirst, there are three files, which corresponds to IANA's\n[Root Zone Database][22]:\n\n* [data/tld-domains.txt][23] - used by tests\n* [src/auto_tld.c][27] - used by the library\n* [include/eav/auto_tld.h][28] - used by the library\n\nThe [data/tld-domains.txt][23] depends on [data/raw.csv][25].\nThe `auto_tld.c` and `auto_tld.h` depends on [data/punycode.csv][24].\n\nSecond, to update these files you need [Perl][19] and [Text::CSV][29]\ninstalled on your system.\n\nThird, you have to obtain CSV files by yourself somehow. I am\nusing the application written to this task, you may find it\nhere: [github: gh0stwizard/iana-tld-extractor][26].\n\nTo update [data/tld-domains.txt][23] use the command below:\n\n```\n% make tld-domains\n```\n\nTo update [src/auto_tld.c][27] and [include/eav/auto_tld.h][28]\nuse the next command:\n\n```\n% make auto\n```\n\n\n## API\n\nWhen compile your application with [idnkit][8], please, pass the\n`-DHAVE_IDNKIT` flag to the compiler.\n\nPlease, read the [developer documentation][20] for details.\n\n\n## Tools\n\nThere is an utility called `eav`. It will be installed by default to\nthe `DESTDIR`/bin directory. It has a simple usage:\n\n```\n% eav emails1.txt emails2.txt\n```\n\nSee its sources in the [bin][12] directory.\n\nThe sample output is:\n\n```\nFAIL: localpart-only\n      email has no domain part\nPASS: i.have.only.ipv4@[8.8.8.8]\nPASS: this-is.ipv6@[IPv6:2001:0db8:0000:0000:0000:ff00:0042:8329]\nPASS: and.this.is.ipv6-ipv4@[IPv6:::ffff:192.0.2.128]\nFAIL: invalid.ipv4@[0.1.2.3]\n      invalid ip address\nFAIL: invalid.ipv6@[IPv6:ge80:1::]\n      invalid ip address\nPASS: valid.ipv6@[IPv6:2001:db8:0:1:1:1:1:1]\nPASS: legacy.valid.ipv6@[IPv6:2001:db8::1:1:1:1:1]\nPASS: xxx.ipv6@[2001:db8:1:1:1:1:1:1]\nPASS: simple@test.com\n```\n\n## Troubleshooting\n\n### libidn issues\n\nThe `idn` command depends on the value of `CHARSET` environment variable.\nAlso, this environment variable affects the behaviour of the **libidn**\nlibrary.\n\nIf you are getting `Character encoding conversion error`, then try to\ncheck and fix the `CHARSET` variable on your system. Depending on the\ntype of the operating system, the correct value may be `utf-8` or\n`UTF-8`, please, refer to the documentation of your system.\n\n## See also\n\n* [github: dertuxmalwieder/libvldmail][21]\n\n\n## Credits\n\n* [UTF-8 decoder][11] by JSON.org\n* [postfix][13] written by Wietse Venema\n\n\n## License\n\nThis software is released under BSD 2-clause \"Simplified\" License.\n\n\n[1]: https://en.wikipedia.org/wiki/Email_address\n[2]: https://tools.ietf.org/html/rfc822\n[3]: https://tools.ietf.org/html/rfc5321\n[4]: https://tools.ietf.org/html/rfc5322\n[5]: https://tools.ietf.org/html/rfc6531\n[6]: https://tools.ietf.org/html/rfc20\n[7]: /src/is_6531_local.c\n[8]: https://jprs.co.jp/idn/index-e.html\n[9]: https://www.gnu.org/software/libidn/\n[10]: https://www.gnu.org/software/make/\n[11]: http://www.json.org/JSON_checker/\n[12]: /bin/\n[13]: http://www.postfix.org/\n[14]: https://tools.ietf.org/html/rfc5322#section-3.4\n[15]: https://tools.ietf.org/html/rfc5322#section-3.4.1\n[16]: /docs/\n[17]: https://www.gnu.org/software/libidn/\n[18]: https://github.com/libidn/libidn2\n[19]: https://www.perl.org/\n[20]: /docs/libeav.3.pod\n[21]: https://github.com/dertuxmalwieder/libvldmail\n[22]: https://www.iana.org/domains/root/db\n[23]: /data/tld-domains.txt\n[24]: /data/punycode.csv\n[25]: /data/raw.csv\n[26]: https://github.com/gh0stwizard/iana-tld-extractor\n[27]: /src/auto_tld.c\n[28]: /include/eav/auto_tld.h\n[29]: https://metacpan.org/pod/Text::CSV\n[30]: https://tools.ietf.org/html/rfc1035\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgh0stwizard%2Flibeav","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgh0stwizard%2Flibeav","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgh0stwizard%2Flibeav/lists"}