Mail2Go is a very lightweight command-line SMTP client written in Go, designed to send emails from the command-line easily.
- Send Emails with Ease: Quickly send emails with subject, body, and multiple recipients.
- Attachments Support: Attach multiple files of various types to your emails.
- HTML and Plain Text: Supports both HTML and plain text formats for email bodies.
- Command Line Interface: Easy-to-use CLI arguments for configuring and sending emails.
- Flexible Configuration: SMTP server, TLS, port, username, and password can be configured through CLI arguments or a JSON configuration file.
- Automatic Configuration File Detection: Will automatically search for a default configuration file in the user's config directory if no configuration file is provided (e.g.,
~/.config/mail2go/config.json
).
- Go 1.22 or higher recommended (for build).
- Access to an SMTP server for sending emails.
-
Download the Linux amd64 binary with wget (more versions on release tab):
wget https://github.com/KeepSec-Technologies/Mail2Go/releases/download/1.1.6/mail2go_linux_amd64_1.1.6.tar.gz
-
Unpack it with tar
tar -xf mail2go_linux_amd64_1.1.6.tar.gz
-
Move it to your /usr/local/bin/ (Optional):
sudo mv mail2go /usr/local/bin/mail2go
-
Ensure you have Go installed on your system. You can download Go from here.
-
Clone the repository:
git clone https://github.com/KeepSec-Technologies/Mail2Go
-
Navigate to the cloned directory:
cd Mail2Go
-
Build the tool:
CGO_ENABLED=0 go build -a -installsuffix cgo -o mail2go .
Run the Mail2Go tool with the required arguments:
-s, --smtp-server SMTP server for sending emails
-p, --smtp-port SMTP server port (Default: 587)
-u, --smtp-username Username for SMTP authentication
-w, --smtp-password Password for SMTP authentication
-l, --tls-mode TLS mode (none, tls-skip, tls)
-f, --from-email Email address to send from
-c, --config Path to the SMTP json config file which replaces the above arguments
-t, --to-email Email addresses that will receive the email, can be multiples (comma-separated)
-h, --subject Subject of the email
-b, --body Body of the email
-af, --attachments File paths for attachments, can be multiples (comma-separated)
-bf, --body-file File path for email body
# Basic example:
mail2go -s mail.example.com -p 587 -u [email protected] -w password123 -l tls -f [email protected] -t [email protected] -h 'Test Mail2Go Subject' -b 'This is a body!'
# Example with two recipients, the body from an HTML file and two attached files (can be more):
mail2go -s mail.example.com -p 587 -u [email protected] -w password123 -l tls -f [email protected] -t [email protected],[email protected] -h 'Test Mail2Go Subject' -bf demo/body.html -af README.md,demo/mail2go-smaller.png
# Example without authentication and no TLS:
mail2go -s mail.example.com -p 25 -l none -f [email protected] -t [email protected] -h 'Test Mail2Go Subject' -b 'This is a body!'
# Example of a local SMTP server with a TLS certificate that can't be verified:
mail2go -s localhost -p 587 -u [email protected] -w password123 -l tls-skip -f [email protected] -t [email protected] -h 'Test Mail2Go Subject' -b 'This is a body!'
Example of json configuration file to pass to Mail2Go:
{
"smtp_server": "mail.example.com",
"smtp_port": 587,
"smtp_username": "[email protected]",
"smtp_password": "password_example",
"tls_mode": "tls",
"from_email": "[email protected]"
}
Example of the command that goes with it:
mail2go -c demo/config.json -t [email protected] -h 'Test Mail2Go Subject' -b 'This is a body!'
If you are using the default configuration file at ~/.config/mail2go/config.json
it would look like this:
mail2go -t [email protected] -h 'Test Mail2Go Subject' -b 'This is a body!'
Note: CLI arguments will override configuration files (from the --config
argument or the default location at ~/.config/mail2go/config.json
).
Contributions to Mail2Go are welcome. Please fork the repository and submit a pull request with your changes or improvements.
This project is licensed under MIT - see the LICENSE file for details.