{"id":19364345,"url":"https://github.com/davidfstr/notifymail","last_synced_at":"2025-04-23T14:30:51.895Z","repository":{"id":9659380,"uuid":"11597951","full_name":"davidfstr/notifymail","owner":"davidfstr","description":"Allows scripts to send email to a preconfigured address.","archived":false,"fork":false,"pushed_at":"2018-10-27T00:40:24.000Z","size":153,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-02T05:39:05.700Z","etag":null,"topics":["automation","email","email-sender"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"krhorst/active_admin_importable","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidfstr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-23T02:50:23.000Z","updated_at":"2024-06-13T06:21:31.000Z","dependencies_parsed_at":"2022-08-07T05:01:13.009Z","dependency_job_id":null,"html_url":"https://github.com/davidfstr/notifymail","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fnotifymail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fnotifymail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fnotifymail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fnotifymail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidfstr","download_url":"https://codeload.github.com/davidfstr/notifymail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223926589,"owners_count":17226443,"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":["automation","email","email-sender"],"created_at":"2024-11-10T07:37:10.481Z","updated_at":"2024-11-10T07:37:11.033Z","avatar_url":"https://github.com/davidfstr.png","language":"Python","readme":"# notifymail\n\n`notifymail` allows scripts to send email to a preconfigured address. It is particularly useful for unattended and scheduled scripts to report their status to an administrator.\n\n`notifymail` is designed to be very easy to install and use. I wrote it because I couldn't figure out how to configure the built-in `sendmail` command to forward emails appropriately and I couldn't get the similar `ssmtp` package to work.\n\n## Requirements\n\n* OS X or Linux\n* Python 2.7 or 3.4\n* An email account\n\n## Installation\n\n```\n$ pip install notifymail  # or pip3 (for Python 3.x)\n```\n\n## Configuration\n\nYou must know the SMTP settings of your email provider, which can typically looked up on your provider's website. For example here are [Gmail's SMTP settings](https://support.google.com/mail/troubleshooter/1668960?hl=en#ts=1665119,1665162), obtained with a internet search for \"gmail SMTP settings\":\n\n* **Gmail SMTP Server:** smtp.gmail.com\n* **Gmail SMTP Port:** 587 (for TLS)\n* **Gmail SMTP Uses TLS?** yes\n\nUsually your SMTP username will be the same as your email address, and your SMTP password will be the same as your email password.\n\nOnce you have the settings in hand, run the `notifymail.py --setup` command:\n\n```\n$ notifymail.py --setup\nSMTP Server Hostname: smtp.gmail.com\nSMTP Server Port [465]: 587\nSMTP Server Uses TLS (y/n) [n]: yes\nSMTP Username: robot@gmail.com\nSMTP Password: ********\nFrom Address [robot@gmail.com]: robot@gmail.com\nFrom Name (optional) []: notifymail\nTo Address: admin@example.com\n\nVerifying connection to SMTP server... OK\n```\n\n## Usage\n\n### From the Command Line\n\n```\n$ echo \"Hello World\" | notifymail.py -s \"Subject\"\n```\n\n`notifymail` will read the message body from standard input and allow you to specify a subject line with the `-s` option. You may also specify a custom sender name using the `--from-name` option.\n\nIn Python 2 the encoding of the message body and all arguments is assumed to be UTF-8.\nIn Python 3 the encoding of both is autodetected in [the usual fashion](https://docs.python.org/3/library/sys.html#sys.stdin).\n\nFull usage information:\n\n```\nUsage: notifymail.py --setup | -s SUBJECT [-b BODY] [--from-name NAME] | --probe\n\nOptions:\n  -h, --help            show this help message and exit\n  --setup               setup mail server configuration\n  --probe               check whether mail server is reachable\n  -s SUBJECT, --subject=SUBJECT\n                        subject line. Required.\n  -b BODY, --body=BODY  body. Read from standard input if omitted.\n  --from-name=NAME      sender name. Overrides the default sender name.\n```\n\n### From a Python Script\n\n```\nimport notifymail\nnotifymail.send('Subject', 'Hello World')\n```\n\nString arguments can be either Unicode strings or UTF-8 encoded bytestrings.\n\n### From a Non-Python Script\n\nJust execute the `notifymail` command using your language's normal API for running system commands.\n\nFor example, in Ruby:\n\n```\nrequire 'open3'\n\nOpen3.popen3('notifymail.py', '-s', 'Subject') {|stdin, stdout, stderr, wait_thr|\n  stdin.puts('Hello World!')\n  stdin.close\n  \n  exit_code = wait_thr.value.to_i\n  if exit_code != 0\n    raise \"notifymail exited with error code #{exit_code}.\"\n  end\n}\n```\n\nFor example, in Java:\n\n```\nimport java.io.*;\n\ntry {\n    Process notifymail = Runtime.getRuntime().exec(new String[] {\n        \"notifymail.py\", \"-s\", \"Subject\" });\n    PrintStream stdin = new PrintStream(\n        notifymail.getOutputStream(), /*autoFlush=*/false, \"UTF-8\");\n    \n    stdin.println(\"Hello World!\");\n    stdin.close();\n    \n    int exitCode = notifymail.waitFor();\n    if (exitCode != 0) {\n        throw new Exception(\"notifymail exited with error code \" + exitCode + \".\");\n    }\n} catch (Exception e) {\n    throw new RuntimeException(\"Unable to send email.\", e);\n}\n```\n\n## Limitations\n\n* The configured SMTP settings are stored in plaintext, including the SMTP password.\n\n## License\n\nThis code is provided under the MIT License.\n\n## Release Notes\n\n* 1.1\n    * Add support for Python 3.4. Remove support for Python 2.6.\n    * Fix `--from-name` to actually work.\n    * Fix `--setup` to not print usage info after completing setup.\n* 1.0\n    * Initial version.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfstr%2Fnotifymail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidfstr%2Fnotifymail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfstr%2Fnotifymail/lists"}