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
93 changes: 57 additions & 36 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,16 +107,26 @@ client.send_batch(
)
```

### Usage Examples
### Sandbox Sending

Refer to the [`examples`](examples) folder for more examples:
Send emails to your Sandbox inbox for testing purposes:

```ruby
require 'mailtrap'

client = Mailtrap::Client.new(api_key: 'your-api-key', sandbox: true, inbox_id: YOUR_INBOX_ID)
client.send(mail)

- [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)
# You can also pass the request parameters directly
client.send(
from: { email: 'mailtrap@example.com', name: 'Mailtrap Test' },
to: [
{ email: 'your@email.com' }
],
subject: 'You are awesome!',
text: 'Congrats for sending test email with Mailtrap!'
)
```

### 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.


Expand All @@ -134,32 +146,41 @@ configuration example.

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:
and bulk APIs. Refer to the configuration examples above.

```ruby
# config/application.rb
ActionMailer::Base.add_delivery_method :mailtrap_bulk, Mailtrap::ActionMailer::DeliveryMethod
## Supported functionality & Examples

# 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)
```
Refer to the [`examples`](examples) folder for more examples:

Email API:
- Full email sending – [`full.rb`](examples/full.rb)

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

Email Sandbox (Testing):

- Project management CRUD – [`projects_api.rb`](examples/projects_api.rb)

Contact management:

- Contacts CRUD & listing – [`contacts_api.rb`](examples/contacts_api.rb)

General API:

- 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 +189,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.