{"id":19475478,"url":"https://github.com/artdecocode/email","last_synced_at":"2026-06-07T21:31:50.413Z","repository":{"id":57098885,"uuid":"235342818","full_name":"artdecocode/email","owner":"artdecocode","description":"Send e-mails by direct connection to recepient's SMPT server.","archived":false,"fork":false,"pushed_at":"2020-01-22T10:21:04.000Z","size":109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T07:46:56.820Z","etag":null,"topics":["e-mail","email","smtp"],"latest_commit_sha":null,"homepage":"https://www.artd.eco","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artdecocode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-21T12:57:01.000Z","updated_at":"2020-01-22T10:21:06.000Z","dependencies_parsed_at":"2022-08-20T17:30:40.369Z","dependency_job_id":null,"html_url":"https://github.com/artdecocode/email","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"mnpjs/package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Femail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Femail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Femail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artdecocode%2Femail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artdecocode","download_url":"https://codeload.github.com/artdecocode/email/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240699252,"owners_count":19843510,"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":["e-mail","email","smtp"],"created_at":"2024-11-10T19:33:06.182Z","updated_at":"2025-02-25T15:47:07.161Z","avatar_url":"https://github.com/artdecocode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @artdeco/email\n\n[![npm version](https://badge.fury.io/js/%40artdeco%2Femail.svg)](https://www.npmjs.com/package/@artdeco/email)\n\n`@artdeco/email` Sends e-mails by direct connection to recipient's SMTP server with authorisation and TLS upgrade support to encrypt messages. You can use this for relay services also, such as https://www.smtp2go.com.\n\n```sh\nyarn add @artdeco/email\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [How Does It Work](#how-does-it-work)\n- [API](#api)\n- [`async email(mail: !Mail, data: { html: string, text: string }, config: !Config): void`](#async-emailmail-maildata--html-string-text-string-config-config-void)\n  * [`Mail`](#type-mail)\n  * [`Config`](#type-config)\n  * [`Dkim`](#type-dkim)\n- [Copyright \u0026 License](#copyright--license)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/0.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## How Does It Work\n\nYou don't need to operate your own SMTP server to send messages: given an email address, you can resolve the MX server of the domain via DNS lookup, and connect to it directly. This package includes an SMTP client that will establish a socket connection, perform TLS upgrade, and authenticate users when necessary (see the bottom of the page for SMTP protocol commands link). After the connection is established, you can just send formatted message.\n\nHowever, due to spam, most hosting providers such as Azure, _etc_ will block port 25 so you won't be able to do that. That's why there are many online services that allow to send messages via so-called relay services via additional ports like 2525. They usually provide an HTTP API as well, but this package has a standard SMTP client. A relay business-model is to maintain high reputation of their servers so that all messages will be delivered. Although there's only a limited number of free messages that can be sent per month, there's pretty much no alternative nowadays for production transactional emails therefore you just have to go with that.\n\nOn the other hand, you might be able to use [Gmail's SMTP server](https://kinsta.com/knowledgebase/free-smtp-server/) if you are a Google Apps customer.\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/1.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport email from '@artdeco/email'\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/2.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## \u003ccode\u003easync \u003cins\u003eemail\u003c/ins\u003e(\u003c/code\u003e\u003csub\u003e\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`mail: !Mail,`\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`data: { html: string, text: string },`\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`config: !Config,`\u003cbr/\u003e\u003c/sub\u003e\u003ccode\u003e): \u003ci\u003evoid\u003c/i\u003e\u003c/code\u003e\nSend e-mails by direct connection to recipient's SMTP server.\nYou will most probably want to use a relay SMTP server, as most cloud server providers (Azure, Alibaba) block port 25 for direct connections.\n\n - \u003ckbd\u003e\u003cstrong\u003email*\u003c/strong\u003e\u003c/kbd\u003e \u003cem\u003e\u003ccode\u003e\u003ca href=\"#type-mail\" title=\"The email object with information about the message.\"\u003e!Mail\u003c/a\u003e\u003c/code\u003e\u003c/em\u003e: The mail to send.\n - \u003ckbd\u003e\u003cstrong\u003edata*\u003c/strong\u003e\u003c/kbd\u003e \u003cem\u003e`{ html: string, text: string }`\u003c/em\u003e: The data.\n - \u003ckbd\u003e\u003cstrong\u003econfig*\u003c/strong\u003e\u003c/kbd\u003e \u003cem\u003e\u003ccode\u003e\u003ca href=\"#type-config\" title=\"Options for the program.\"\u003e!Config\u003c/a\u003e\u003c/code\u003e\u003c/em\u003e: The config.\n\n__\u003ca name=\"type-mail\"\u003e`Mail`\u003c/a\u003e__: The email object with information about the message.\n\n\n|   Name    |                   Type                    |                        Description                         |\n| --------- | ----------------------------------------- | ---------------------------------------------------------- |\n| __from*__ | \u003cem\u003estring\u003c/em\u003e                           | The FROM field, e.g., `Hello World \u003chello@world.com\u003e`.     |\n| __to*__   | \u003cem\u003estring\u003c/em\u003e                           | The TO field, e.g., `Foo Bar \u003cfoo@bar.co\u003e`.                |\n| cc        | \u003cem\u003e(string \\| !Array\u0026lt;string\u0026gt;)\u003c/em\u003e | Carbon copy the message to these recipients.               |\n| bcc       | \u003cem\u003estring\u003c/em\u003e                           | Blind carbon copy (without revealing) to these recipients. |\n| subject   | \u003cem\u003estring\u003c/em\u003e                           | The email subject.                                         |\n\n\n__\u003ca name=\"type-config\"\u003e`Config`\u003c/a\u003e__: Options for the program.\n\n\n|   Name   |                                                                 Type                                                                  |                       Description                       | Default |\n| -------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------- |\n| dkim     | \u003cem\u003e\u003ca href=\"#type-dkim\" title=\"DKIM information for signing messages. If you use a relay, this will not be required.\"\u003e!Dkim\u003c/a\u003e\u003c/em\u003e | DKIM configuration for signing emails.                  | -       |\n| silent   | \u003cem\u003eboolean\u003c/em\u003e                                                                                                                      | Disable printing to console.                            | `false` |\n| smtpHost | \u003cem\u003estring\u003c/em\u003e                                                                                                                       | SMTP host to connect to (e.g., an email relay service). | -       |\n| smtpPort | \u003cem\u003estring\u003c/em\u003e                                                                                                                       | The port to connect to SMTP server.                     | -       |\n| user     | \u003cem\u003estring\u003c/em\u003e                                                                                                                       | The username to use for login.                          | -       |\n| pass     | \u003cem\u003estring\u003c/em\u003e                                                                                                                       | The password for login.                                 | -       |\n\n\n__\u003ca name=\"type-dkim\"\u003e`Dkim`\u003c/a\u003e__: DKIM information for signing messages. If you use a relay, this will not be required.\n\n\n|      Name       |      Type       |                                   Description                                    | Default |\n| --------------- | --------------- | -------------------------------------------------------------------------------- | ------- |\n| __privateKey*__ | \u003cem\u003estring\u003c/em\u003e | The private key.                                                                 | -       |\n| keySelector     | \u003cem\u003estring\u003c/em\u003e | The selector.                                                                    | `dkim`  |\n| domain          | \u003cem\u003estring\u003c/em\u003e | The domain. This will be deducted from your email host from the `mail.to` field. | -       |\n\nWhen `html` and `text` are set, the `multipart/alternative` MIME type is set on the message that contains both representations. If only text is set, it will be sent without a MIME type. There's no way to currently add attachments.\n\n```js\nimport email from '@artdeco/email'\nimport dotEnv from '@demimonde/dotenv'\ndotEnv()\n\nexport default async () =\u003e {\n  const mail = await email({\n    from: 'Akashic \u003cno-reply@akashic.page\u003e',\n    to: 'Art Deco \u003cartdecocode@protonmail.com\u003e',\n    subject: 'Hello World',\n  }, {\n    html: 'HTML \u003cspan style=\"color:red\"\u003etext\u003c/span\u003e',\n    text: 'text',\n  }, {\n    smtpHost: 'mail.smtp2go.com',\n    smtpPort: 2525,\n    user: process.env.SMTP2GO_USER,\n    pass: process.env.SMTP2GO_PASSWORD,\n  })\n  return mail\n}\n```\n```\nMX connection created:  mail.smtp2go.com\nrecv protonmail.com \u003e 220 mail.smtp2go.com ESMTP Exim 4.92-S2G Tue, 21 Jan 2020 21:03:56 +0000\nsend protonmail.com \u003e EHLO akashic.page\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 250-mail.smtp2go.com Hello akashic.page [8.208.77.44]\nrecv protonmail.com \u003e 250-SIZE 52428800\nrecv protonmail.com \u003e 250-8BITMIME\nrecv protonmail.com \u003e 250-DSN\nrecv protonmail.com \u003e 250-PIPELINING\nrecv protonmail.com \u003e 250-AUTH CRAM-MD5 PLAIN LOGIN\nrecv protonmail.com \u003e 250-CHUNKING\nrecv protonmail.com \u003e 250-STARTTLS\nrecv protonmail.com \u003e 250-PRDR\nrecv protonmail.com \u003e 250 HELP\nsend protonmail.com \u003e STARTTLS\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 220 TLS go ahead\nsend protonmail.com \u003e EHLO akashic.page\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 250-mail.smtp2go.com Hello akashic.page [8.208.77.44]\nrecv protonmail.com \u003e 250-SIZE 52428800\nrecv protonmail.com \u003e 250-8BITMIME\nrecv protonmail.com \u003e 250-DSN\nrecv protonmail.com \u003e 250-PIPELINING\nrecv protonmail.com \u003e 250-AUTH CRAM-MD5 PLAIN LOGIN\nrecv protonmail.com \u003e 250-CHUNKING\nrecv protonmail.com \u003e 250-PRDR\nrecv protonmail.com \u003e 250 HELP\nsend protonmail.com \u003e MAIL FROM:\u003cno-reply@akashic.page\u003e\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 250 OK\nsend protonmail.com \u003e RCPT TO:\u003cartdecocode@protonmail.com\u003e\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 250 Accepted \u003cartdecocode@protonmail.com\u003e\nsend protonmail.com \u003e DATA\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 354 Enter message, ending with \".\" on a line by itself\nsend protonmail.com \u003e Subject: Hello World\nFrom: Akashic \u003cno-reply@akashic.page\u003e\nTo: Art Deco \u003cartdecocode@protonmail.com\u003e\nDate: Tue, 21 Jan 2020 21:03:56 GMT\nMIME-Version: 1.0\nMessage-ID: \u003c45fc1664c17fc9a703e6b5d5302ab5632f4bec7b8cbc384e_1579640636645@akashic.page\u003e\nContent-Type: multipart/alternative; boundary=----e07b67289b0d805a68a96f108df443e8\nX-Service: @artdeco/email\n\n------e07b67289b0d805a68a96f108df443e8\nContent-Type: text/html; charset=utf-8\nContent-Transfer-Encoding: quoted-printable\n\nHTML \u003cspan style=\"color:red\"\u003etext\u003c/span\u003e\n------e07b67289b0d805a68a96f108df443e8\nContent-Type: text/plain; charset=utf-8\n\ntext\n\n------e07b67289b0d805a68a96f108df443e8--\nsend protonmail.com \u003e\nsend protonmail.com \u003e .\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 250 OK id=1iu0go-4Xa8vO-Qa\nsend protonmail.com \u003e QUIT\nrecv protonmail.com \u003e\nrecv protonmail.com \u003e 221 mail.smtp2go.com closing connection\nrecv protonmail.com \u003e\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/3.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## Copyright \u0026 License\n\n- [SMTP commands reference](https://www.samlogic.net/articles/smtp-commands-reference.htm)\n\nGNU Affero General Public License v3.0\n\nOriginal work on the SMTP client from [node-sendmail](https://github.com/guileen/node-sendmail) by GreenPioneer, NGTmeaty and others under MIT license. Email formatting and DKIM support from [fannst-nodemailer](http://npmjs.com/package/fannst-nodemailer) by Luke Rieff under ISC license.\n\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/38815725?v=4\u0026amp;s=100\" alt=\"artdecocode\"\u003e\u003c/td\u003e\n    \u003ctd\u003e© \u003ca href=\"https://www.artd.eco\"\u003eArt Deco\u003c/a\u003e 2020\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/-1.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartdecocode%2Femail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartdecocode%2Femail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartdecocode%2Femail/lists"}