diff --git a/README.md b/README.md index 175def3..789356c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -134,25 +146,30 @@ 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 @@ -160,6 +177,10 @@ 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. @@ -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. \ No newline at end of file