{"id":10610090,"url":"https://github.com/yaroslaff/testmsg","last_synced_at":"2025-04-13T07:31:57.553Z","repository":{"id":160684366,"uuid":"635452371","full_name":"yaroslaff/testmsg","owner":"yaroslaff","description":"Generate/send RFC-compliant e-mail messages. DKIM signed (optionally). Can send over SSL/TLS with authentication. Gmail.com and mail-tester.com are happy!","archived":false,"fork":false,"pushed_at":"2024-10-23T16:34:56.000Z","size":43,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-23T18:43:45.435Z","etag":null,"topics":["antispam","body","client","craft","dkim","dkim-signing","e-mail","email","generate","headers","mail","message","msmtp","python","rfc822","send","smtp","spam","test","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaroslaff.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}},"created_at":"2023-05-02T18:17:04.000Z","updated_at":"2024-10-23T16:34:28.000Z","dependencies_parsed_at":"2024-02-16T17:52:17.530Z","dependency_job_id":"a33609a9-ad66-44b0-9334-b44cf2591117","html_url":"https://github.com/yaroslaff/testmsg","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2Ftestmsg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2Ftestmsg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2Ftestmsg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2Ftestmsg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaroslaff","download_url":"https://codeload.github.com/yaroslaff/testmsg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223573816,"owners_count":17167383,"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":["antispam","body","client","craft","dkim","dkim-signing","e-mail","email","generate","headers","mail","message","msmtp","python","rfc822","send","smtp","spam","test","testing"],"created_at":"2024-06-02T09:27:08.541Z","updated_at":"2024-11-07T19:17:53.815Z","avatar_url":"https://github.com/yaroslaff.png","language":"Python","readme":"# testmsg\nGenerate RFC822 compliant e-mail messages for tests and send it over SMTP.\n\nWhile it's easy to send test messages like `echo asdf | mail you@gmail.com` or via `telnet mx.example.com 25` I need a tool which:\n- Generates valid messages\n- Messages should not look spammy or very suspicious\n- Easy to use and repeat test\n- Ability to customize messages\n- Work well with msmtp or other full-featured SMTP client (e.g. which can send over secure SMTP connection with authentication)\n- Support DKIM signatures\n\n## Installation\nFor current user, using [pipx](https://github.com/pypa/pipx)\n~~~\npipx install testmsg\n~~~\nor globally:\n~~~\nPIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install testmsg\n~~~\n\nor (old way, better if inside virtualenv):\n~~~\npip3 install testmsg\n~~~\n\n\n## Usage example\nJust generate minimal valid message, print to stdout (not sending). \n\n~~~\n$ testmsg --to you@gmail.com  --lorem \nContent-Type: text/plain; charset=\"utf-8\"\nContent-Transfer-Encoding: quoted-printable\nMIME-Version: 1.0\nSubject: Sent with github.com/yaroslaff/testmsg\nFrom: from@example.com\nTo: you@gmail.com\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempo=\nr incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut al=\niquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore =\neu fugiat nulla pariatur.\nExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia des=\nerunt mollit anim id est laborum.\n~~~\n\n## Options\n\nYou can pass options either as command-line arguments or in `.env` file. Example:\n~~~\nFROM=noreply@example.com\nTO=me@example.net\nSUBJECT=\"My subj\"\n\n# Only one of next three is possible at same time\n# TEXT=\"Hello, world!\"\n# MSG=/tmp/helloworld.txt\nLOREM=1\n\n# add timestamp to message body\nTIMESTAMP=1\n\n# if we want to send message, set mailserver host there. Otherwise testmsg will just print to stdout\nSEND=localhost\n\n# You may override port (e.g. 587)\n# PORT=25\n\n# SMTP authentication\n# If SMTPPASS given, will use SMTP authentication. Default SMTPUSER is same as FROM\n# SMTPUSER=aaa@bbb.com\nSMTPPASS=\"MySecretPassword\"\n\n# use 1 for True, anything else for False\nSSL=0\nSTARTTLS=1\n\n# DKIM (very very optional)\n# DKIM_SELECTOR=\"mail\"\n# DKIM_PRIVKEY=/etc/ssl/private/test.example.com.pem\n\nVERBOSE=1\n~~~\nTo enable boolean option use value \"1\", to disable - any other value.\n\nWith such .env file, you can send message with just `testmsg` command (no options).\n\n### Sending  message\nTo actually send message via SMTP server add `--send localhost` and optionally add `-v` for verbosity.\n~~~\ntestmsg -v --lorem --from you@example.net --to you@gmail.com --send localhost\n~~~ \n\nSee below about how to use authentication and  SSL/TLS and how to use with `msmtp` (or other smtp clients).\n\n### Customize message\nUse `--from`, `--to` and `--subject` to override basic properties of message, use `--add HEADER VALUE` to add custom header(s).\n\nTo set `Return-Path` header (address used in `MAIL FROM` SMTP command) to custom value, use `-r` / `--return`, e.g. `--return noreply@gmail.com`.\n\nDefault message text is empty, use `--text \"blah blah blah\"` or `--lorem` or `--msg PATH` or `--msg -` .(to read from stdin). Add `--time` to add current time as an prefix to text.\n\n### Add attachments\nUse `--attachment` (or `--att`) to add attachments: `--att FILE1 FILE2 ...`\n\n### Sign with DKIM\n\nGenerate DKIM RSA keys:\n~~~shell\n# generate private RSA key for DKIM\nopenssl genrsa -out example.com.pem 1024\n# generate public key for DKIM\nopenssl rsa -in example.com.pem -out example.com.pub -pubout\n~~~\n\nMake DKIM DNS record with as `SELECTOR`._domainkey.example.com and verify it (here I decide to use selector `mail`):\n~~~shell\n$ host -t txt mail._domainkey.example.com\nmail._domainkey.example.com.net descriptive text \"v=DKIM1; h=sha256; k=rsa; p=MII....\"\n~~~\n\nsend DKIM signed message to gmail or mail-tester.com! Use `--selector` and `--privkey` arguments.\n~~~shell\ntestmsg -f test@example.com -t mailbox@gmail.com --lorem --selector mail --privkey example.com.pem -v --send localhost\n~~~\n\n## Use with authentication and SSL/STARTTLS SMTP servers\n\nTo use authentication, use `--user` and `--password` (or `--pass`) parameters. Use `--ssl` to use SSL-capable SMTP server (port 465), or use `--starttls` to use `STARTTLS` SMTP command. If neither `--ssl` nor `--starttls` is given, message and authentication credentials are sent over plain unencrypted connection, which is highly insecure.\n\nIf `--user` is not given (but `--password` given), testmsg will use username same as from (`--from` / `-f`) address. \n\nExample:\n\n~~~\ntestmsg -v -f test1@example.com -t somebody@example.net --lorem --pass \"MyTestPass\" --send mx.example.com --starttls\n~~~\n\n## Use together with msmtp\n\nHere we send with TLS and authentication (using [msmtp](https://github.com/marlam/msmtp)). Username for authentication (`--user`) is same as FROM address. Testmsg generates valid message and msmtp sends it.\n\n~~~\nFROM=sender@example.com\nTO=recipient@gmail.com\n\ntestmsg -f $FROM -t $TO --lorem | msmtp -v --host smtp.office365.com --port 587 --user $FROM --passwordeval='echo MyTestPass' -f $FROM --tls=on --auth=on $TO\n~~~","funding_links":[],"categories":["Sending"],"sub_categories":["Email Testing Application"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaroslaff%2Ftestmsg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaroslaff%2Ftestmsg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaroslaff%2Ftestmsg/lists"}