Skip to content

Repository files navigation

gomail

Actions Status Go Report Card License Tag

A powerful and flexible mail sender written in Go

English | 简体中文


📖 Introduction

gomail is a robust mail sending utility written in Go, designed to simplify email delivery with support for attachments, templates, and flexible recipient management.

⚙️ Prerequisites

  • Go >= 1.24.0

✨ Features

gomail provides comprehensive email functionality:

  • 📎 Attachments - Send multiple file attachments with ease
  • 📝 HTML and Text Templates - Support for both HTML and plain text content
  • 👥 Recipient Management - Advanced recipient parsing with CC support
  • 🔍 Filtering - Email domain filtering capabilities
  • 🧪 Dry Run Mode - Validate recipients without sending

🚀 Quick Start

Build from Source

# Clone the repository
git clone https://github.com/craftslab/gomail.git

# Navigate to the project directory
cd gomail

# Build the project
make build

The compiled binaries will be available in the bin/ directory.

📋 Usage

Parser Tool

Parse and filter recipient email addresses:

./parser \
  --config="config/parser.json" \
  --filter="@example1.com,@example2.com" \
  --recipients="alen,cc:bob@example.com"

Sender Tool

Send emails with various options:

./sender \
  --config="config/sender.json" \
  --attachment="attach1.txt,attach2.txt" \
  --body="body.txt" \
  --content_type="PLAIN_TEXT" \
  --header="Your Name" \
  --recipients="alen@example.com,bob@example.com,cc:catherine@example.com" \
  --title="TITLE"

Note: The --header option specifies the display name for the sender. The actual From email address is taken from the sender field in the config file. For example, if config contains "sender": "noreply@example.com" and you use --header="Your Name", the From header will be: "Your Name" <noreply@example.com>.

📚 Command Line Reference

Parser Command

Description: Parse and filter email recipients

usage: parser --recipients=RECIPIENTS [<flags>]

Recipient parser

Flags:
      --help                   Show context-sensitive help (also try --help-long
                               and --help-man).
      --version                Show application version.
  -c, --config=CONFIG          Config file, format: .json
  -f, --filter=FILTER          Filter list, format: @example1.com,@example2.com
  -r, --recipients=RECIPIENTS  Recipients list, format: alen,cc:bob@example.com

Sender Command

Description: Send emails with attachments and templates

usage: sender --recipients=RECIPIENTS [<flags>]

Mail sender

Flags:
      --help                     Show context-sensitive help (also try
                                 --help-long and --help-man).
      --version                  Show application version.
  -a, --attachment=ATTACHMENT    Attachment files, format: attach1,attach2,...
  -b, --body=BODY                Body text or file
  -c, --config=CONFIG            Config file, format: .json
  -e, --content_type=PLAIN_TEXT  Content type, format: HTML or PLAIN_TEXT
                                 (default)
  -r, --header=HEADER            Sender display name (used with sender address
                                 from config file)
  -p, --recipients=RECIPIENTS    Recipients list, format:
                                 alen@example.com,cc:bob@example.com
  -t, --title=TITLE              Title text
  -n, --dry-run                  Only output recipient validation JSON and exit;
                                 do not send

📄 License

This project is licensed under the terms specified in the LICENSE file.

🔗 Related Projects

  • rsmail - Related mail project

Made with ❤️ by craftslab

About

Mail sender in Go

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages