How to send email using Email API?
An alternative way of having to send functionality in your Rails application is using an API offered by email service providers. This is one of the most reliable ways to set up an automated email-sending function in your app quickly and not worry about constant deliverability issues popping up.
With a service such as Mailtrap Email API, you can also get additional control over your email deliverability. The dashboards with valuable insights and up to 60 days of email logs give an accurate understanding of where your email infrastructure stands.
After a quick setup of the Email AP/SMTP Relay, your app can start sending emails hassle-free. If any issues arise, the email deliverability alerts feature will always let you know. Email API’s system automatically checks your metrics every three hours, and in case of a critical drop in a predetermined threshold, the alert is sent on an hourly basis, thus giving you even more control over email deliverability. On top of that, there are weekly reports that help understand your performance.
If you use ActionMailer in your Rails app for email-sending functionality, thanks to a custom Mailtrap delivery method, the API can also be integrated with it.
Firstly add this line to your app’s Gemfile:
$ gem install mailtrap
Then execute:
$ bundle install
Alternatively, install it yourself:
$ gem install mailtrap
Now set the API key and configure the delivery method in your ActionMailer configuration in Rails projects located in config/$ENVIRONMENT.rb
: