{"id":13565886,"url":"https://github.com/mludvig/smtp-cli","last_synced_at":"2026-01-12T13:23:05.405Z","repository":{"id":44486727,"uuid":"2603845","full_name":"mludvig/smtp-cli","owner":"mludvig","description":"The ultimate command line SMTP client","archived":false,"fork":false,"pushed_at":"2020-08-23T13:08:07.000Z","size":113,"stargazers_count":195,"open_issues_count":14,"forks_count":33,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-01-11T15:54:46.724Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://smtp-cli.logix.cz","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mludvig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-19T03:31:52.000Z","updated_at":"2025-11-05T08:04:48.000Z","dependencies_parsed_at":"2022-09-15T22:01:52.891Z","dependency_job_id":null,"html_url":"https://github.com/mludvig/smtp-cli","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/mludvig/smtp-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mludvig%2Fsmtp-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mludvig%2Fsmtp-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mludvig%2Fsmtp-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mludvig%2Fsmtp-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mludvig","download_url":"https://codeload.github.com/mludvig/smtp-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mludvig%2Fsmtp-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-08-01T13:01:57.235Z","updated_at":"2026-01-12T13:23:05.363Z","avatar_url":"https://github.com/mludvig.png","language":"Perl","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=R8BYGL3B24QNE"],"categories":["Perl"],"sub_categories":[],"readme":"smtp-cli — command line SMTP client\n===================================\n\n`smtp-cli` is a powerful **SMTP command line client** with a support for advanced features, such as **STARTTLS**, **SMTP-AUTH**, or **IPv6** and with a scriptable _message composition_ capabilities supporting anything from simple _plain-text_ messages right up to building _complex HTML emails_ with alternative plain-text part, attachments and inline images. The MIME-Type of the attachments can either be guessed automatically or alternatively set on the command line, separately for each attachment if required.\n\nIt's also a convenient tool for _testing_ and _debugging_ SMTP servers setups. Even the hardcore mail admins used to typing the SMTP protocol over telnet need a specialised tool when it comes to verifying encryption settings of their TLS enabled server with a subsequent user authentication. Such things are pretty hard to type into a telnet session by hand :-)\n\nThe name `smtp-cli` stands for:\n\n1. **smtp-cli**ent\n2. **S**mtp-command **L**ine **I**nterface\n\nUse `smtp-cli` if you want to:\n\n1. check mail server capabilities\n2. test the server setup\n3. create and send complex emails from scripts or cron-jobs\n\nThe `smtp-cli` usage is intuitive, everything is scriptable and can run in a completely non-interactive mode from various scripts or cron jobs. It is also ideal for shipping log files from remote machines, running periodical mail delivery test loops, etc. Also if you ever needed to send a complex email with attachments from a command line, this script is all you need.\n\n## Installation\n\nDownload the latest release from [smtp-cli on GitHub](https://github.com/mludvig/smtp-cli/releases) and make it executable:\n\n```sh\n~ $ wget -o smtp-cli https://github.com/mludvig/smtp-cli/releases/{LATEST_RELEASE}\n~ $ chmod +x smtp-cli\n```\n\n### Optional dependencies\n\nSome features of smtp-cli are optional and available only when the appropriate perl modules are installed:\n\n* RedHat Enterprise (RHEL), Fedora, Oracle Linux and CentOS users may want to install the following packages:\n\n  ```sh\n  $ sudo yum install  perl-IO-Socket-SSL  perl-Digest-HMAC  perl-TermReadKey  \\\n\t                    perl-MIME-Lite  perl-File-LibMagic  perl-IO-Socket-INET6\n  ```\n  \n  If `yum` can't find them all try to enable [EPEL repository](http://fedoraproject.org/wiki/EPEL).\n\n* openSUSE and SUSE Enterprise (SLES) users should install these packages:\n\n  ```sh\n  $ sudo zypper install  perl-IO-Socket-SSL  perl-Digest-HMAC  perl-TermReadKey  \\\n\t                       perl-MIME-Lite  perl-File-LibMagic  perl-IO-Socket-INET6\n  ```\n\n* Users of Debian, Ubuntu and derivates should install these packages:\n\n  ```sh\n  $ sudo apt install  libio-socket-ssl-perl  libdigest-hmac-perl  libterm-readkey-perl \\\n\t                    libmime-lite-perl libfile-libmagic-perl libio-socket-inet6-perl\n  ```\n \nUsers of other Linux distributions will have to find the appropriate packages by themselves, or install the modules directly from [CPAN](http://cpan.perl.org/).\n\n## Donate please :)\n\nPlease consider donating, even if it's just enough for a coffee. \n\n[![Donate with PayPal](examples/PayPal-Donate-Button-PNG-Image.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=R8BYGL3B24QNE)\n\n\n\n## Usage examples\n\nThese examples are for _testing_ and _verifying_ mail servers configurations:\n\n### Example 1 - Test your localhost\n\nThe simplest example - it will not actually send anything. Only connect to a server, do some SMTP chatting and disconnect.\n\n```\n$ ./smtp-cli --verbose --server localhost\n[220] 'localhost ESMTP Postfix'\n\u003e EHLO localhost\n[250] 'localhost'\n[250] 'PIPELINING'\n[250] 'SIZE 20480000'\n[250] 'ETRN'\n[250] '8BITMIME'\n\u003e QUIT\n[221] 'Bye'\n```\n\n### Example 2 - Send an e-mail through a host which requires encryption and authentication\n\nThings are getting more interesting. We will use `--server smtp.example.com:587` to connect to port 587\nthat is usually used by email clients (port 25 is usually for server-to-server communication). Port 587\nalso _usually_ requires authentication.\n\nFor that we'll supply `--user test` and optional `--password ...` to supply the credentials. \nIf the password is not supplied we will be asked interactively.\n\nTo actually send something we will also supply `--from` and `--to` parameters and also `--data message.txt`. \n\nNote tat this `message.txt` must contain both the _headers_ and the _message body_. If you don't want to \nbother with creating the message headers yourself use `--body` instead, see the next example for details.\n\n```\n$ ./smtp-cli --verbose --host smtp.example.com:587 --enable-auth --user test \\\n--from test@example.com --to user@another.example.org --data message.txt\n\n[220] 'smtp.example.com ESMTP Postfix'\n\u003e EHLO localhost\n[250] 'smtp.example.com'\n[250] 'PIPELINING'\n[250] 'SIZE 10240000'\n[250] 'VRFY'\n[250] 'ETRN'\n[250] 'STARTTLS'\n[250] 'XVERP'\n[250] '8BITMIME'\nStarting TLS...\n\u003e STARTTLS\n[220] 'Ready to start TLS'\nUsing cipher: EDH-RSA-DES-CBC3-SHA\nSubject Name: /C=XX/CN=smtp.example.com/Email=info@example.com\nIssuer  Name: /C=XX/CN=Example.COM Root CA/Email=ca@example.com\n\u003e EHLO localhost\n[250] 'smtp.example.com'\n[250] 'PIPELINING'\n[250] 'SIZE 10240000'\n[250] 'VRFY'\n[250] 'ETRN'\n[250] 'AUTH PLAIN LOGIN DIGEST-MD5 CRAM-MD5'\n[250] 'AUTH=PLAIN LOGIN DIGEST-MD5 CRAM-MD5'\n[250] 'XVERP'\n[250] '8BITMIME'\nAUTH method (PLAIN LOGIN DIGEST-MD5 CRAM-MD5): using CRAM-MD5\n\u003e AUTH CRAM-MD5\n[334] 'PDE0OTQyOTcxOC4yNjAwOTYwQHNlcnZlci5kb21haW4udG9wPg=='\n\u003e dGVzdCBmOTUyY2RkM2VlODBiMzk1YjYxNDI4NjBlYzg2Y2ExZnJvb3Q=\n[235] 'Authentication successful'\nAuthentication of test@localhost succeeded\n\u003e MAIL FROM: \u003ctest@example.com\u003e\n[250] 'Ok'\n\u003e RCPT TO: \u003cuser@another.example.org\u003e\n[250] 'Ok'\n\u003e DATA\n[354] 'End data with \u003cCR\u003e\u003cLF\u003e.\u003cCR\u003e\u003cLF\u003e'\n[250] 'Ok: queued as C5C3A299D7'\n\u003e QUIT\n[221] 'Bye'\n```\n\n### Example 3 - Compose a plain text email with attachments\nFor composing emails you will need an optional `MIME::Lite` perl module. See the _Optional dependencies_ section above for details.\n\n```\n$ ./smtp-cli [--server / --auth / --verbose flags] \\\n             --from test@domain.com --to user@another.domain.org \\\n             --subject \"Simple test with attachments\" \\\n             --body-plain \"Log files are attached.\" \\\n             --attach /var/log/some.log@text/plain \\\n             --attach /var/log/other.log\n```\n\nThis example composes a standard plain text email with two attachments. The interesting part is the syntax used for enforcing _MIME-Type_ of the first attachment. \n\nThe syntax `some.log@text/plain` will make `some.log` attached as **text/plain** part, while the _MIME-Type_ of `other.log` will be guessed by the script and eventually default to **application/octet-stream**.\n\n### Example 4 - Attachment as an email body\n```\n$ ./smtp-cli [--server / --auth / --verbose flags] \\\n             --from test@domain.com --to user@another.domain.org \\\n             --subject \"Image as a mail body\" \\\n             --attach /path/to/tux.png\n```\n\nIf there is only one text or image file to be sent, the file itself could be the message body. At the same time it will be accessible as an attachment with a file name for easy saving. Best to show a screenshot I guess...\n\n![Attachment as an email body](examples/screenshot-img-body.png)\n\nThere is no _Text_ or _HTML_ body part and the email is not _multipart/mixed_. All that is in the email is Tux the Penguin image. You can immediately see it in your mailer but also can easily save it with its provided name tux.png. The same way it works with text files (or files forced to be text/plain, to be precise).\n\n### Example 5 - Compose a multipart/alternative email with both HTML and Plain text part and inline images\n\nSending HTML emails is popular, especially among non-technical people. They like to change font colours, backgrounds, embed images and apply all sorts of other useless effects to their one short line of text. Indeed, me and you are more than happy with plain text and we both know that some mail readers can't even display colours and graphics at all (our office manager wouldn't believe!). Therefore it is a good practice for HTML messages to use **multipart/alternative** MIME format with _both_ HTML and TEXT parts. In this example we're going to go wild and even embed an inlined image or two into the HTML part.\n\nFirst of all prepare the message body. Or bodies, actually. The HTML one is `body.html`:\n\n```html\n\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\u003e\n\u003chtml\u003e\n\u003chead\u003e\u003c/head\u003e\n\u003cbody bgcolor=\"#ffffff\" text=\"#000000\"\u003e\n\u003cdiv align=\"center\"\u003e\nHere comes embedded \u003cfont color=\"#006600\"\u003e\u003cb\u003eMr Tux\u003c/b\u003e\u003c/font\u003e\u003cbr\u003e\n\u003cimg src=\"cid:tux.png\"\u003e\u003cbr\u003e\n\u003ci\u003eNice, isn't it?\u003c/i\u003e\u003cbr\u003e\n\u003cimg src=\"cid:smiley.png\"\u003e\u003cbr\u003e\n\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nNote the `\u003cimg\u003e` tags with `cid:filename.xyz` source — that's the way to refer _inlined attachments_ from inside the message. We will obviously have to inline-attach `tux.png` and `smiley.png` to the message to make it work.\n\nThe second body file is a _plain text_ representation of the above, call it `body.txt`:\n\n```\nHere comes embedded Mr Tux\n... actually it doesn't ... \nNot in a text-only mail reader.\nSorry\n```\n\nThat's it. Here comes the magic command line that puts it all together:\n\n```\n$ ./smtp-cli --from test@domain.com --to user@another.domain.org \\\n             --subject \"HTML with embedded image\" \\\n             --body-html body.html --body-plain body.txt \\\n             --attach-inline tux.png --attach-inline smiley.png\n```\n\nAnd this is what we get:\n\n![Multipart HTML email with embedded image](examples/screenshot-img-inline.png)\n\n## Donate please :)\n\nPlease consider donating, even if it's just enough for a coffee. \n\n[![Donate with PayPal](examples/PayPal-Donate-Button-PNG-Image.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=R8BYGL3B24QNE)\n\n\n## Author\n\n**Michael Ludvig** - get in touch through the [Issues](https://github.com/mludvig/smtp-cli/issues) section above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmludvig%2Fsmtp-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmludvig%2Fsmtp-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmludvig%2Fsmtp-cli/lists"}