sendpy

πŸ“§ Send e-mail (and text messages) from the command line

https://github.com/tdulcet/send-msg-cli

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • βœ“
    CITATION.cff file
    Found CITATION.cff file
  • βœ“
    codemeta.json file
    Found codemeta.json file
  • βœ“
    .zenodo.json file
    Found .zenodo.json file
  • β—‹
    DOI references
  • β—‹
    Academic publication links
  • βœ“
    Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • β—‹
    Institutional organization owner
  • β—‹
    JOSS paper metadata
  • β—‹
    Scientific vocabulary similarity
    Low similarity (13.3%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

πŸ“§ Send e-mail (and text messages) from the command line

Basic Info
  • Host: GitHub
  • Owner: tdulcet
  • License: gpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 408 KB
Statistics
  • Stars: 9
  • Watchers: 2
  • Forks: 5
  • Open Issues: 1
  • Releases: 0
Created over 6 years ago · Last pushed 8 months ago
Metadata Files
Readme License Citation

README.md

Actions Status

Send Msg CLI

Send e-mail (and text messages) from the command line

Copyright Β© 2019 Teal Dulcet (both) and Daniel Connelly (Python)

Send e-mail (and text messages), with optional message and attachments, from the command line. Supports Unicode characters in the display names, subject, message and attachment filenames (MIME). Wrapper around cURL and the mail command to easily send e-mails from the command line. Optionally use your own e-mail address and an external SMTP server.

Useful to know when a cron job failed, when a long running job (LRP) has finished, to quickly backup/share a file or to send notifications as part of a larger script.

See the python directory for SendPy, a Python port of the script.

❀️ Please visit tealdulcet.com to support these scripts and my other software development.

Usage

Supports Unix, including both Linux and macOS. Requires at least Bash 4.4 and cURL, which are included on most Linux distributions.

Optional S/MIME digital signatures require OpenSSL.\ Optional PGP/MIME digital signatures require GNU Privacy Guard (GPG).\ Optional attachment compression requires the zip command.

Run: ./sendmsg.sh <OPTION(S)>... -s <subject>\ One or more To, CC or BCC e-mail addresses are required. Send text messages by using the mobile providers e-mail to SMS or MMS gateway. All the options can also be set by opening the script in an editor and setting the variables at the top. See Help below for full usage information.

  1. Verify that the required commands above are installed.
  2. Download the script (sendmsg.sh). Run: wget https://raw.github.com/tdulcet/Send-Msg-CLI/master/sendmsg.sh.
  3. At a minimum, you need to provide one To e-mail address. If the computer is on a residential network or if it does not have an SMTP server setup then you will also need to provide an external SMTP server. For security, any passwords/passphrases should be set in the script, instead of on the command line.
  4. Execute the script once to make sure there are no errors. For example, run: chmod u+x sendmsg.sh and ./sendmsg.sh -s "Test" -m "This is a test!" -t "Example <example@example.com>" -d.
  5. If you want the script to be available for all users, install it. Run: sudo cp sendmsg.sh /usr/local/bin/sendmsg and sudo chmod +x /usr/local/bin/sendmsg.

Examples

See Help below for more examples.

Send a notification when a long running job (LRP) has finished, with the exit code and output: bash output=$(myLRP arg1 arg2… 2>&1); ./sendmsg.sh -s "β€œmyLRP arg1 arg2…” has finished"'!' -m "The program β€œmyLRP arg1 arg2…” has finished on β€œ$HOSTNAME”"'!'"\nExit code: $?\nOutput:\n$output\n" Replace myLRP arg1 arg2… with the actual program and arguments.

Backup/Share a file: bash ./sendmsg.sh -s "Log file" -m "Please see the attached log file." -a status.log

Send notifications as part of a larger script: bash ./sendmsg.sh -s "⬇️ Example Website is DOWN"'!' -m "Example Website (https://www.example.com/) is currently DOWN"'!'"\n\nThis script will alert you when it is back up.\n" Example adapted from the Linux Remote Servers Status Monitoring Script.

Gmail

Instructions To send e-mail from a Gmail account, add these options to the command: `-f "User " -S "smtps://smtp.gmail.com" -u "example@gmail.com" -p "PASSWORD"`. Or, open the script in an editor and set these variables near the top, where listed: ```bash FROMEMAIL="User " SMTP="smtps://smtp.gmail.com" USERNAME="example@gmail.com" PASSWORD="PASSWORD" ``` Replace `example` with the username and `PASSWORD` with the actual password. For security, the password should be set in the script, instead of on the command line. You will also need to either create an [App Password](https://support.google.com/accounts/answer/185833) or enable "Less secure app access": https://myaccount.google.com/lesssecureapps. It is not actually less secure, since it is using the same SSL/TLS encryption (note the `smtps://` protocol). Note that Google may disable this setting if it is not being used. If you get a "Login denied" error, try visiting this page: https://accounts.google.com/DisplayUnlockCaptcha.

Feature comparison

This Send E-mail Script S-nail (formerly Heirloom mailx) Mutt SSMTP SendEmail eMail smtp-cli
Send e-mail βœ” βœ” βœ” βœ” βœ” βœ” βœ”
Send text messages (e-mail to SMS) βœ” βœ” βœ” βœ” βœ” βœ” βœ”
Use your own e-mail address βœ”* βœ”* βœ”* βœ” βœ” βœ” βœ”
Use an external SMTP server βœ”* βœ”* βœ”* βœ” βœ”* βœ”* βœ”*
Include attachment(s) βœ” βœ” βœ” βœ” βœ” βœ”
Send e-mails to CC and BCC addresses βœ” βœ” βœ” βœ” βœ”
Supports e-mail addresses with display names βœ” βœ” βœ” βœ” βœ”
Supports HTML formatted messages βœ” βœ”
Supports Unicode characters in subject and message (MIME) βœ” βœ” βœ” βœ” βœ” Message only
Supports International email addresses βœ”β€  βœ” βœ”
Supports E-mail Priority βœ” High Priority only
Digitally sign e-mails S/MIME certificate βœ” βœ” βœ”
PGP/MIME βœ” βœ” βœ”
Does NOT require compiling or installing anything βœ”
100% Open Source βœ” βœ” βœ” βœ” βœ” βœ” βœ”
Free πŸ†“ πŸ†“ πŸ†“ πŸ†“ πŸ†“ πŸ†“ πŸ†“

* Optional\ † Only supported in Internationalizing Domain Names in Applications (IDNA) encoding

This is not a comprehensive list of the Send E-mail Script’s functionality.

Source: S-nail, Mutt, SSMTP, SendEmail (archived, source), eMail and smtp-cli

Help

``` $ sendmsg -h Usage: sendmsg ... -s or: sendmsg

Options: -s Subject Escape sequences are expanded. Supports Unicode characters. -m Message body Escape sequences are expanded. Supports Unicode characters. -a Attachment filename Use multiple times for multiple attachments. Supports Unicode characters in filename. -t To e-mail address Use multiple times for multiple To e-mail addresses. -c CC e-mail address Use multiple times for multiple CC e-mail addresses. -b BCC e-mail address Use multiple times for multiple BCC e-mail addresses. -f From e-mail address

-S <SMTP server>SMTP server
                    Supported protocols: "smtp" and "smtps". Requires From e-mail address. Use "smtp://localhost" if running a mail server on this device.
-u <username>   SMTP server username
-p <password>   SMTP server password
-P <priority>   Priority
                    Supported priorities: "5 (Lowest)", "4 (Low)", "Normal", "2 (High)" and "1 (Highest)". Requires SMTP server.
-r              Request Return Receipt
                    Requires SMTP server.
-C <certificate>S/MIME Certificate filename for digitally signing the e-mails
                    It will ask you for the password the first time you run the script with this option. Requires SMTP server.
-k <passphrase> PGP secret key passphrase for digitally signing the e-mails with PGP/MIME
                    Requires SMTP server.
-z <zipfile>    Compress attachment(s) with zip
-l              Set Content-Language
                    Uses value of LANG environment variable.
-U              Sanitize the Date
                    Uses Coordinated Universal Time (UTC) and rounds date down to whole minute. Set the TZ environment variable to change time zone.
-T <seconds>    Time to delay sending of the e-mail
-d              Dry run, do not send the e-mail
-V              Verbose, show the client-server communication
                    Requires SMTP server.

-h              Display this help and exit
-v              Output version information and exit

Examples: Send e-mail $ sendmsg -s "Example" -t "User user@example.com"

Send e-mail with message
$ sendmsg -s "Example" -m "This is an example!" -t "User <user@example.com>"

Send e-mail with message and single attachment
$ sendmsg -s "Example" -m "This is an example!" -a example.txt -t "User <user@example.com>"

Send e-mail with message and multiple attachments
$ sendmsg -s "Example" -m "This is an example!" -a example1.txt -a example2.txt -t "User <user@example.com>"

Send e-mail to a CC address
$ sendmsg -s "Example" -t "User 1 <user1@example.com>" -c "User 2 <user2@example.com>"

Send e-mail with a From address
$ sendmsg -s "Example" -f "Example <example@example.com>" -t "User <user@example.com>"

Send e-mail with an external SMTP server
$ sendmsg -s "Example" -f "Example <example@example.com>" -S "smtps://mail.example.com" -u "example" -p "password" -t "User <user@example.com>"

Send high priority e-mail
$ sendmsg -s "Example" -f "Example <example@example.com>" -S "smtps://mail.example.com" -u "example" -p "password" -P "1 (Highest)" -t "User <user@example.com>"

Send e-mail digitally signed with an S/MIME Certificate
$ sendmsg -s "Example" -f "Example <example@example.com>" -S "smtps://mail.example.com" -u "example" -p "password" -C "cert.p12" -t "User <user@example.com>"

Send e-mail digitally signed with PGP/MIME
$ sendmsg -s "Example" -f "Example <example@example.com>" -S "smtps://mail.example.com" -u "example" -p "password" -k "passphrase" -t "User <user@example.com>"

```

Scripts where this is incorporated

Contributing

Pull requests welcome! Ideas for contributions:

Bash: * Send e-mails with very long subjects or many e-mail addresses * Support International email addresses * Currently they are only supported in Internationalizing Domain Names in Applications (IDNA) encoding. * Support inputting the message body from standard input (stdin)

Python: * Do not create temporary files for performance and to reduce disk wear.

Both: * Improve the performance * Support HTML formatted messages * Provide an option to automatically upload large files to an external storage service, such as Send (provided by @timvisee, formerly Firefox Send) or transfer.sh * Add tests * Automatically renew the S/MIME certificate, as certbot does for Let's Encrypt certificates

Thanks to Daniel Connelly for helping create the Feature comparison and test the Bash script!

Owner

  • Name: Teal Dulcet
  • Login: tdulcet
  • Kind: user
  • Location: Portland, Oregon

πŸ‘¨β€πŸ’» Computer Scientist, BS, CRTGR, MS @Thunderbird Council member

Citation (CITATION.cff)

cff-version: 1.2.0
title: Send E-mail Script
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Teal
    family-names: Dulcet
    orcid: 'https://orcid.org/0009-0008-6616-2631'
repository-code: 'https://github.com/tdulcet/Send-Msg-CLI'
abstract: >-
  Send e-mail (and text messages), with optional message and
  attachments, from the command line. Optionally use your
  own e-mail address and an external SMTP server.
license: GPL-3.0
version: '1.0.1'

GitHub Events

Total
  • Delete event: 3
  • Push event: 6
  • Create event: 4
Last Year
  • Delete event: 3
  • Push event: 6
  • Create event: 4

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 20
  • Total Committers: 2
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.1
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Teal Dulcet t****t@p****u 18
Daniel Connelly c****0@g****m 2
Committer Domains (Top 20 + Academic)
pdx.edu: 1

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 1
  • Total pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: almost 2 years
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Danc2050 (1)
Pull Request Authors
  • Danc2050 (3)
Top Labels
Issue Labels
enhancement (1) help wanted (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 12 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 4
  • Total maintainers: 2
pypi.org: sendpy

Email and text notification program

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 12 Last month
Rankings
Dependent packages count: 7.4%
Forks count: 14.3%
Stargazers count: 17.7%
Dependent repos count: 22.3%
Average: 27.3%
Downloads: 75.0%
Maintainers (2)
Funding
  • https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NJ4PULABRVNCC
Last synced: 8 months ago

Dependencies

python-port/setup.py pypi