Giter Club home page Giter Club logo

mailtrap-ruby's Introduction

test

Official Mailtrap Ruby client

This Ruby gem offers integration with the official API for Mailtrap.

Quickly add email sending functionality to your Ruby application with Mailtrap.

(This client uses API v2, for v1 refer to this documentation)

Installation

Add this line to your application's Gemfile:

gem 'mailtrap'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install mailtrap

Usage

Minimal

require 'mailtrap'

# create mail object
mail = Mailtrap::Mail::Base.new(
  from: { email: '[email protected]', name: 'Mailtrap Test' },
  to: [
    { email: '[email protected]' }
  ],
  subject: 'You are awesome!',
  text: "Congrats for sending test email with Mailtrap!"
)

# create client and send
client = Mailtrap::Client.new(api_key: 'your-api-key')
client.send(mail)

Refer to the examples folder for other examples.

Content-Transfer-Encoding

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). Meaning your recipients will receive emails only in the default encoding which is quoted-printable, if you send with Mailtrap API.

For those who does need to use 7bit or any other encoding, SMTP provides better flexibility in that regard. Go to your Mailtrap accountEmail SendingSending DomainsYour domainSMTP/API Settings to find the SMTP configuration example.

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.

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

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.

mailtrap-ruby's People

Contributors

artheanos avatar ayanko avatar i7an avatar igordobryn avatar leonid-shevtsov avatar mklocek avatar r4do avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailtrap-ruby's Issues

Fetch API key from MAILTRAP_API_TOKEN or MAILTRAP_API_KEY

When adding Mailtrap as a Heroklu add-on, it will add MAILTRAP_API_TOKEN to your app environments.

But, even if you set up your Action Mails like the following:

config.action_mailer.delivery_method = :mailtrap

ActionMailer::Base.smtp_settings = {
  api_key: ENV.fetch("MAILTRAP_API_TOKEN")
}

I will get a 500 Error key not found: "MAILTRAP_API_KEY" Did you mean? "MAILTRAP_API_TOKEN", as this gem is expection to have MAILTRAP_API_KEY present.

I would expect, it uses the set-up I am providing or fallback to MAILTRAP_API_TOKEN.

Broken devise's html template

Hey guys.

Just switched from mailgun to mailtrap and got problem with standard devise's emails.
Particularly with "password restoration" email template.
image

I'm not 100% sure it's caused by mailtrap. But it seems like I didn't change anything else, except changing from one gem to another.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.