Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 29 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Mailtrap Ruby client - Official

![Ruby](https://img.shields.io/badge/Ruby-CC342D)
[![test](https://github.com/mailtrap/mailtrap-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/mailtrap/mailtrap-ruby/actions/workflows/main.yml)
[![docs](https://shields.io/badge/docs-rubydoc.info-blue)](https://rubydoc.info/gems/mailtrap)
[![gem](https://shields.io/gem/v/mailtrap)](https://rubygems.org/gems/mailtrap)
[![downloads](https://shields.io/gem/dt/mailtrap)](https://rubygems.org/gems/mailtrap)


## Prerequisites

# Official Mailtrap Ruby client

This Ruby gem offers integration with the [official API](https://api-docs.mailtrap.io/) for [Mailtrap](https://mailtrap.io).
To get the most out of this official Mailtrap.io Ruby SDK:

Quickly add email sending functionality to your Ruby application with Mailtrap.
- [Create a Mailtrap account](https://mailtrap.io/signup)

(This client uses API v2, for v1 refer to [this documentation](https://mailtrap.docs.apiary.io/))
- [Verify your domain](https://mailtrap.io/sending/domains)

## Installation

Expand Down Expand Up @@ -105,61 +107,39 @@ client.send_batch(
)
```

### Usage Examples
## Supported functionality & Examples

Refer to the [`examples`](examples) folder for more examples:

- [Full](examples/full.rb)
- [Email template](examples/email_template.rb)
- [Batch Sending](examples/batch.rb)
- [ActionMailer](examples/action_mailer.rb)
- [Email Templates API](examples/email_templates_api.rb)
- [Projects API](examples/projects_api.rb)
Email API:
- Full email sending – [`full.rb`](examples/full.rb)

### Content-Transfer-Encoding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you simply removed a chunk of documentation. Maybe it should be moved somewhere instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, my idea was that if other libs are not utilizing these points, it means these points were suppressed on its way to our SDK documentation formats. These 2 paragraphs 'Content-Transfer-Encoding' and 'Multiple Mailtrap Clients' are not existing in other major libraries while they absolutely make same sense to be there.

Do you vote for me to keep them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah lets keep them. Those chapters were added to address customer requests. I dont see the value in removing the documentation. If your goal is to unify the structure, please do that and keep the existing docs.

- Batch sending – [`batch.rb`](examples/batch.rb)

`mailtrap` gem uses Mailtrap API to send emails. Mailtrap API does not try to
replicate SMTP. That is why you should expect some limitations when it comes to
sending. For example, `/api/send` endpoint ignores `Content-Transfer-Encoding`
(see `headers` in the [API documentation](https://railsware.stoplight.io/docs/mailtrap-api-docs/67f1d70aeb62c-send-email)).
Meaning your recipients will receive emails only in the default encoding which
is `quoted-printable`, if you send with Mailtrap API.
Email Sandbox (Testing):

For those who need to use `7bit` or any other encoding, SMTP provides
better flexibility in that regard. Go to your _Mailtrap account_ → _Email Sending_
→ _Sending Domains_ → _Your domain_ → _SMTP/API Settings_ to find the SMTP
configuration example.
- Project management CRUD – [`projects_api.rb`](examples/projects_api.rb)

### Multiple Mailtrap Clients
Contact management:

You can configure two Mailtrap clients to operate simultaneously. This setup is
particularly useful when you need to send emails using both the transactional
and bulk APIs. Refer to the configuration example below:
- Contacts CRUD & listing – [`contacts_api.rb`](examples/contacts_api.rb)

```ruby
# config/application.rb
ActionMailer::Base.add_delivery_method :mailtrap_bulk, Mailtrap::ActionMailer::DeliveryMethod
General API:

# config/environments/production.rb
config.action_mailer.delivery_method = :mailtrap
config.action_mailer.mailtrap_settings = {
api_key: 'your-api-key'
}
config.action_mailer.mailtrap_bulk_settings = {
api_key: 'your-api-key',
bulk: true
}

# app/mailers/foo_mailer.rb
mail(delivery_method: :mailtrap_bulk)
```
- Templates CRUD – [`email_templates_api.rb`](examples/email_templates_api.rb)

- Action Mailer – [`action_mailer.rb`](examples/action_mailer.rb)

## Migration guide v1 → v2

Change `Mailtrap::Sending::Client` to `Mailtrap::Client`.

If you use classes which have `Sending` namespace, remove the namespace like in the example above.

## Contributing

Bug reports and pull requests are welcome on [GitHub](https://github.com/railsware/mailtrap-ruby). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand All @@ -168,18 +148,18 @@ To install this gem onto your local machine, run `bundle exec rake install`.

To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on [GitHub](https://github.com/mailtrap/mailtrap-ruby). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).

All contributions are required to have rspec tests covering its functionality.

Please be sure to update [README](README.md) with new examples and features when applicable.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the Mailtrap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
Everyone interacting in the Mailtrap project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).

## Compatibility with previous releases

Versions of this package up to 2.0.2 were an [unofficial client](https://github.com/vchin/mailtrap-client) developed by [@vchin](https://github.com/vchin). Package version 3 is a completely new package.