Skip to content

fuinorg/sjsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Java Send Mail (sjsm)

A simple command line application for sending mails.

Java Maven Build LGPLv3 License Java Development Kit 11

Versions

  • 0.2.x = Java 11 with new 'jakarta' namespace

  • 0.1.0 = Java 8

Why?

Sometimes it's nice to have a way to send an email without installing anything (except Java) on the system. For example, it could be used in an AWS CodeBuild "buildspec.yml" to send a mail on a failing build. It's like sSMTP, but without a configuration file. Only command line arguments are used to configure mail server, receiver, message and other stuff.

Requirements

Make sure you have Java 11 installed on your machine.

Running the application

You can download the latest JAR file here: https://github.com/fuinorg/sjsm/releases

java -jar sjsm-0.4.0-SNAPSHOT.jar <arguments>

Command line arguments

Argument Value Required Example
-host SMTPS server name yes "smtp.no-where-no-no.com"
-port SMTPS port number (SSL/TLS) yes 465
-user Your mailbox user yes "acc12345_from.not.exist" or "from.not.exist@no-where-no-no.com" (depends on your mail provider)
-pw Your mailbox password (Either pwor envPw is mandatory) no -
-envPw Name of an environment variable that contains your mailbox password no -
-from Sender's email address yes "from.not.exist@no-where-no-no.com"
-to Receiver's email address (multiple separated with ";") yes "to.not.exist@no-where-no-no.com" or "jane.doe@no-where-no-no.com;john.doe@no-where-no-no.com"
-subject Mail subject yes "My subject"
-message Message body (TEXT or HTML) yes "<html><body><h1>This is a test mail</h1></body></html>"
-html - no -
-charset Mail encoding (defaults to "utf-8") no "utf-8"
-important Send High Priority Email (X-Priority flag) no -

TEXT example

java -jar sjsm-0.4.0-SNAPSHOT.jar \
	-host "smtp.no-where-no-no.com" \
	-port 465 \
	-user "acc12345_from.not.exist" \
	-pw "xxxxxxx" \
	-from "from.not.exist@no-where-no-no.com" \
	-to "to.not.exist@no-where-no-no.com" \
	-subject "My subject" \
	-message "This is a test mail"

HTML example

java -jar sjsm-0.4.0-SNAPSHOT.jar \
	-host "smtp.no-where-no-no.com" \
	-port 465 \
	-user "acc12345_from.not.exist" \
	-pw "xxxxxxx" \
	-from "from.not.exist@no-where-no-no.com" \
	-to "to.not.exist@no-where-no-no.com" \
	-subject "My html subject" \
	-message "<html><body><h1>This is a test mail</h1></body></html>" \
	-html \

CAUTION

⚠️ Be aware that passing your password via the command line (-pw) will most probably be visible in your command line history. It's better to use an environment variable with -envPw.


Snapshots & Releases

There will be no more releases/snapshots on Maven Central but only here.