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, port, username, and password can be configured through CLI arguments or a JSON configuration file.
- Go 1.20 or higher recommended (for build).
- Access to an SMTP server for sending emails.
-
Download the binary with wget:
wget https://github.com/KeepSec-Technologies/Mail2Go/releases/download/1.1.3/mail2go_linux_amd64_1.1.3.tar.gz
-
Unpack it with tar
tar -xf mail2go_linux_amd64_1.1.3.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
-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, comma-separated
-h, --subject Subject of the email
-b, --body Body of the email
-af, --attachments File paths for attachments, comma-separated
-bf, --body-file File path for email body
Those arguments would look like this in your CLI:
./mail2go --smtp-server [SMTP_SERVER] --smtp-port [SMTP_PORT] --smtp-username [USERNAME] --smtp-password [PASSWORD] --from-email [FROM_EMAIL] --to-email [TO_EMAIL_1],[TO_EMAIL_2] --subject "Your Subject" --body "Your email body." --attachments "path/to/attachment1,path/to/attachment2"
or
./mail2go --config "path/to/config.json" --to-email [TO_EMAIL_1],[TO_EMAIL_2] --subject "Your Subject" --body-file "path/to/email.html" --attachments "path/to/attachment1,path/to/attachment2"
Basic example:
./mail2go -s mail.example.com -u user@example.com -w password123 -f mail2go@example.com -t admin@example.com -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 -u user@example.com -w password123 -f mail2go@example.com -t admin@example.com,other@example.com -h 'Test Mail2Go Subject' -bf demo/body.html -af README.md,demo/mail2go-smaller.png
Example of json config file to pass to Mail2Go:
{
"smtp_server": "mail.example.com",
"smtp_port": 587,
"smtp_username": "user@example.com",
"smtp_password": "password123",
"from_email": "mail2go@example.com"
}
The command that goes with it:
./mail2go -c demo/config.json -t admin@example.com -h 'Test Mail2Go Subject' -b 'This is a body!'
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.