A powerful and flexible Ruby script for sending HTML emails via SMTP with robust configuration and error handling.
- 🔐 Secure SMTP configuration
- 🌈 Flexible environment-based settings
- 💻 Command-line interface support
- 🛡️ Comprehensive error handling
- 🔧 Easy customization
- Ruby 2.7+ 💎
- Bundler gem 📦
- Clone the repository:
git clone https://github.com/cortona/email_sender.git
cd email_sender- Install dependencies:
bundle install- Create a
.envfile with your SMTP credentials:
SMTP_FROM_EMAIL=sender@example.com
SMTP_TO_EMAIL=recipient@example.com
SMTP_USERNAME=your_username
SMTP_PASSWORD=your_password
SMTP_HOST=smtp.yourprovider.com
SMTP_PORT=587ruby email_sender.rb -t recipient@example.com -s "Hello!" -b body.html-f, --from EMAIL: Sender email address-t, --to EMAIL: Recipient email address-s, --subject SUBJECT: Email subject-b, --body HTML_FILE: Path to HTML body file
| Variable | Description | Default |
|---|---|---|
SMTP_FROM_EMAIL |
Sender's email | Required |
SMTP_TO_EMAIL |
Recipient's email | Required |
SMTP_SUBJECT |
Default email subject | "Test Email" |
SMTP_HOST |
SMTP server address | "localhost" |
SMTP_PORT |
SMTP server port | 25 |
SMTP_AUTHENTICATION |
SMTP auth method | "login" |
SMTP_ENABLE_STARTTLS |
Enable STARTTLS | true |
- Validates required email configuration
- Provides clear error messages
- Graceful failure with exit codes
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Martin - m.schneider@cortona.de
Project Link: https://github.com/cortona/email_sender
Made with ❤️ and Ruby 💎