Description

A very easy interface for sending simple text based emails.

Installation

gem install ez-email

Adding the trusted cert

gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/ez-email/main/certs/djberg96_pub.pem)

Synopsis

require 'ez-email'

# Simple email
EZ::Email.deliver(
  :to      => 'your_friend@hotstuff.com',
  :from    => 'you@blah.com',
  :subject => 'Hello',
  :body    => 'How are you?'
)

# Email with attachments
EZ::Email.deliver(
  :to          => 'your_friend@hotstuff.com',
  :from        => 'you@blah.com',
  :subject     => 'Files attached',
  :body        => 'Please find the attached files.',
  :attachments => ['/path/to/file1.pdf', '/path/to/file2.txt']
)

Rationale

When I originally created this library the existing list of email handling libraries were either not designed for sending email, were extremely cumbersome, had lousy interfaces, or were no longer maintained.

I just wanted to send a flippin’ email! This library scratched that itch. Hopefully you will find its simplicity useful, too.

Features

API

The library supports these options:

All file attachments are automatically base64 encoded and sent with appropriate MIME types.

Local Testing

To run the specs you will need a mail server running locally. If you do not already have a mail server running on port 1025 then install docker and run the following command:

docker compose run mailhog

Once the mailhog docker image is installed and a container is running, you can run the specs. You can also view the emails that were generated by pointing your web browser at localhost:8025 after running the specs for visual verification.

Bugs

None that I’m aware of. Please log any bug reports on the project page at

github.com/djberg96/ez-email.

See Also

The “pony” gem at github.com/benprew/pony.

License

Apache-2.0

© 2009-2023, Daniel J. Berger, All Rights Reserved

Author

Daniel Berger