SendGrid implementation with Heroku - ruby-on-rails

We are using Heroku to host our Rails app, and are looking to send out our mail via ActionMailer. I just signed up for SendGrid, paid, and have a fully provisioned account ready to start firing off these emails. How should i go about implementing? through Heroku as an "add-on", or via the Rails documentation found on SendGrid's site?

If you use the add-on, a new SendGrid account will be created with a randomly assigned username and password. Since you already have an account, you will need to reset the relevant Heroku environment variables to your existing credentials if you use the addon. Other than that, there should be no difference between letting Heroku generate the settings or doing it by hand.
Edit: Another difference is that if you use the addon, billing works a little differently. Heroku cannot currently bill overages, so if you are on a 40,000 email credits / month plan, that 40,000 is a hard limit. If your account is via SendGrid.com, it's a soft limit that allows you to pay overages if you send more mail.

Related

Can i send and receive emails using ActionMailer in development env.?

I am trying to design a email confirmation but not able to receive emails in my gmail account. Can anyone help ?
one-step confirmation in gmail does not work;
you must enable 2-step gmail verification and enable app password;
dotenv doesn't load the passwords to production - you have to feed heroku in CLI heroku config:set var1=value1, etc. or at the link https://dashboard.heroku.com/apps/<your_application>/settings (this last tip does not apply to development).
For a specific trouble, please:
a) detail the code and error; or
b) make available your public repository in github.

Gmail::Client::AuthorizationError only in Production for Rails App on Heroku

I have a RoR app that reads emails from my inbox using the gmail gem. I've deployed to Heroku and everything works fine, except connecting to gmail.
On my local machine it connects with no issues (after I allowed access for less secure apps).
Using the basic gmail login method;
Gmail.connect!('my_email#gmail.com','password')
I get the following error in production only.
Gmail::Client::AuthorizationError: Couldn't login to given Gmail account: my_email#gmail.com (Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure))
And then I'll go to https://www.google.com/accounts/DisplayUnlockCaptcha (as other answers have suggested) and it will work fine for a short time period and then suddenly stop working again.
I'm using Ruby v2.4.1, RoR v5.1.1 and the gmail gem v0.6.0 (https://github.com/gmailgem/gmail)
Any help would be great.
Are you deploying to a domain? It could be caused by the fact that:
Heroko will not give you even a range of IP addresses - they can, may and will move dynos between Amazon zones as needs require.
Your only option would be some sort of proxy node with a static IP that they talk to that securely communicates to your Heroku app - or consider if Heroku is the right fit for you here altogether.
Source: Get a finite list of IP addresses for my Heroku App?
It seems like you sign into Google and whitelist what an IP (as far as they're concerned) and then the dyno switches a bit later for whatever reason so then Google no longer has your dyno's IP in the whitelist for this app.

Is it possible to receive e-mail using Google Apps for Work (gmail) with a heroku domain?

I have a Google for Work account and I'm creating an e-mail address with my herokuapp domain (e.g. me#myapp.herokuapp.com). I have verified the domain by putting the meta tag in the header of my app. I can send e-mail through gmail from me#myapp.herokuapp.com but for some reason I can't receive e-mail. I'm curious what is causing the problem of the e-mail not going through.
If anyone has some insight, I would appreciate it. I know that it's possible to receive e-mail by using a custom domain in my heroku app, but I don't want to spend the money on a custom domain right now.
As mentioned by miketreacy, you would need to configure the DNS records for your herokuapp.com subdomain to point to the Google server.
This is not something Heroku allows you to do though. The only way you can send and receive emails from your app is with your own domain name.
Your MX records are not set to Google's. Currently, the MX records are listed as these. In order to receive emails at this domain - in your Apps account - you'll need to modify your DNS to match the MX records listed on Google's Support site.

Mandrill Inbound email- setting up Sending Domains with an app hosted on Heroku

I am trying to learn the ins and outs of Mandrill, so I created a test app that has no functionality except creating users, signing them in and out, and clicking on a link that sends the user an e-mail through ActionMailer.
So far all of this works fine. I have configured Mandrill to send e-mail in both development and production (Heroku). What I'm trying to do now is configure it to receive e-mails sent from users and do stuff with them. My problem is that I'm not sure what to add as my mail domain in the Sending Domains section of my Mandrill account page.
I've done this before with an app on Heroku using Mailgun. Mailgun gave me a Mailgun subdomain to use for user testing off the bat (app12345678.mailgun.org). I was able to send mail to postmaster#app12345678.mailgun.org and it worked perfectly. With Mandrill it's proven a bit more difficult.
Mandrill doesn't seem to provide a Mandrill subdomain to start with. I suppose my question is: is it at all possible to get a Mandrill subdomain for testing like the one Mailgun provides? If not, how can I go about user testing inbound e-mail with Mandrill if I don't currently own my own custom domain? What can I use as the Sending Domain?
it's not currently possible to use Mandrill's inbound email routing unless you have a domain/subdomain to work with. We don't provide a testing subdomain to use for inbound routing.
Any domains you actually send from in Mandrill will be added to the Sending Domains page. You don't have to manually enter any domains there, since we'll detect any that you use and show them there automatically. If you want to set up SPF and DKIM for your sending domain, you can manually add it in order to validate the records have been added correctly.
If you have other questions specific to your account, our support team is also happy to help if you want to get in touch via the Support button in your account.

How to create individual email id to users on my domain through rails?

I would like to create an email service for all the users on my site, for example: abc#xyz.com, where users will be able to send and receive personalized emails. To start I only need to be able to send and receive emails in Rails.
Users need to be able to register an email at xyz.com and to send and receive emails from xyz.com.
Are there any solutions already available in Rails? Is there any gem or plugin that do this?
If I need to start from scratch, any resource that might helpful for solving the problem would be much appreciated.
Assuming you want to store these users in a SQL database, perhaps you can configure an MTA and an IMAP server to use your Rails database as the user database, then use Squirrelmail or any other web mail client to provide the e-mail user interface.
I believe both Dovecot IMAP server and the Postfix MTA can use MySQL or PostgreSQL to lookup/authenticate users.
There seems to be a webmail app in Rails http://mailr.org/.

Resources