I am in need of help figuring out a how to set up incbound email with Griddler and Gmail for Work. I've got a Rails 4 that I'm trying to configure to receive incoming emails using Griddler and SendGrid. I followed the instructions on the Griddler readme exactly. Next I created a tunnel to my localhost environment using ngrok.io. I then went into the SendGrid web app and created a webhook to catch emails going to example.com and send them to the url abc123.ngrok.io.
So far, I think I've got the setup correct. Next I set up an MX record in my domains DNS zone file. The host is # and it points to mx.sendgrid.net.
Here is where things get tricky for me. My site has Gmail for Work set up. I'm not super particular on the details, but essentially, I want a way for users to send a message to foo#bar.example.com and have it routed to Griddler, rather than Gmail. The format of the email address is not terribly important except that it must be dynamic in the sense that foo can be replaced with anything and it will still be routed to Griddler, as long as the domain is bar.example.com. If the domain is just example.com, then it should be routed to Gmail.
I've not had much luck finding resources on how to set this up.
Thanks!
You need to configure 2 separate MX records, one for example.com, and one for bar.example.com. Have the subdomain record point to SendGrid, and have the domain use gmail's MX.
Related
I have a Rails app running on Heroku that uses Mailgun to process incoming emails. I haven't been able to figure how I can debug my email processing locally (on localhost) instead of having to push everything up to heroku every time I make a change. (this is just a test app - I'm the only one using it)
Is it possible to work with Mailgun locally? If so, how do I go about it?
Thank you in advance
Mailgun gives you the option to store a message for later retrieval. If you configure it that way, you'll be able to fetch messages from development for processing without having to set up a publicly-accessible webhook for Mailgun to hit.
But I'm assuming you have production configured with an HTTP endpoint, and it's no fun to do things differently between environments. There are a few tools that will let you set up a public endpoint that routes to localhost:
ngrok, which I've used to good effect to test Twilio. You can set up a permanent subdomain so you don't have to constantly change your Mailgun configuration.
UltraHook, which I haven't personally used, but looks the same.
Localtunnel which looks easiest to start up, but like you get a different host at every boot.
If you have a permanent publicly-accessible server, you can also maintain your own tunnel.
mailgun provides a sandbox that you can use for localhost the only downside to this is that you have to add the test email to valid recipient.
using this gem might be another possible solution:
https://github.com/ryanb/letter_opener/ or https://github.com/fgrehm/letter_opener_web for more advanced features
follow installation from repo
mail will open in new tab
One issue I'm seeing with Devise is that confirmation emails can go to the spam folder. If the user could simply respond to the email, that would serve to confirm the email address and it would train gmail that the sender is not spam.
Any recommendation on if this is worth doing and how would I do it?
Or maybe there's a much easier way to avoid having sent application mails go to spam?
I've been having the exact same issue, and after a long night I believe I have it sorted out.
1) Make sure you have an SPF record set up for your domain.
2) Set up DKIM on your mail server and put your public key in your DNS (TXT record).
3) Make sure your html email is properly formatted ( I had to add the html opening and closing tags to mine, Devise did not do this by default).
4) The last piece of the puzzle was making sure I was sending both plaintext and html MIME parts in my emails. Just creating an additional plaintext 'text.erb' file for each of my mail views seemed to do the trick (Rails auto-magically picked it up and constructed multipart emails for me).
You can verify 1 and 2 are setup right by viewing the 'original' email within Gmail and making sure you see something like "spf=pass" and "dkim=pass" in the headers.
A friend informed me about a service called SendGrid (and I'm sure there are other service providers that do exactly the same thing) after I had spent nearly an entire night going from WTH is DKIM? -- to getting way more familiar with SMTP, DNS, and postfix than I ever wanted to be. But it works now, and I'm probably too cheap to pay for a third party service anyway :)
This is not Devise's fault. Devise actually follows the best practices concerning confirmation of email address.
I believe you fall in the category of bulk email senders, and that you will have to follow quite a few guidelines to sort this out.
I would advise you to go through Google help pages for more information on how to fix this:
Configuration help: https://support.google.com/mail/bin/answer.py?hl=en&answer=81126
Help wizard: https://support.google.com/mail/bin/static.py?hl=en&ts=2696779&page=ts.cs
I'm fairly new to Ruby on Rails and actually entirely new to website mailing. In a lot of example tutorials I see a "from" object assigned to, for example, "new#example.com". When I setup the emailing functionality on a localhost the RoR command prompt says that everything finished fine even when I keep "new#example.com" as the from object. Can I actually mail from a localhost port? What would I have to put as my "from" address in order to actually send mail from the my local web application? Just a regular email I have? How would it be authenticated to ensure that the "from" address is actually the real address?
It seems a really fundamental concept and I understand all the model/view/controller actions that have to be done to make it work but I'm confused I guess as to how it actually works
In general the from field can be anything.
Some mail servers may take action if they think that you are claiming to be someone you are not, such as blocking mail or marking it as spam (via mechanisms such as DKIM or SPF). These are done at the domain level, ie the mail server tries to work out whether the server talking to it is allowed to send email claiming to be from #example.com.
Other mail servers mail just silently rewrite your from field if they know who you are, for example if you are talking to the gmail smtp servers and have authenticated as bob then the from field will be set to bob#gmail.com, unless it is already set to an email address gmail knows you own.
By default, in development rails doesn't try and send email at all. For it to send email you need to configure the deluvery_method, usually this involves either setting it to :sendmail (if you have an appropriately configured instance of sendmail running locally) or setting to :smtp and also providing details of an smtp server to use.
In one of my Rails applications I'm sending emails through the Gmail SMTP server and everything just works, mails are not going to spam and so on ... But there's one thing that concerns me, the 500messages/day limit the SMTP has, currently I'm over 350/day. I didn't find any official Google page where they talk about the subject, just blog posts that seems to be reliable. Then my question is what do you suggest me in order to be able to send more than 500messages/day? I would love to keep using the Gmail SMTP.
Any help would be appreciated.
Don't use GMail for what it wasn't built for. It wasn't designed as a mass-email system, although Google definitely has the firepower to do this.
Instead, perhaps use something like SendGrid to send your emails. SendGrid is designed for this and is just as easy (actually, probably easier) to set up with than GMail.
You can consider using more than one gmail account to access the smtp server, however you may have problems with ip limits (couldn't find anything on their docs about it). Another option is performing dns mx lookups yourself and reproducing your own smtp server by directly delivering the messages to the user's emails - but that can increase the odds of you being tagged as a spammer as your ip is not whitelisted as sender.
I think the best way is to create another gmail account and trying to reroute your connection to use it when one of the accounts reaches the daily limit. A vpn connection can solve that for you.
I have google apps for receiving email. I get inquiries from people on info#[my-domain.com], which email is hosted on google.
Sometimes, I want my rails set-up to send emails from my own server, and that works fine. But when I want to send to an email address on my own domain, such as info#my-domain.com, postfix sees the my-domain.com and tries to deliver locally.
I understand that's normal, but I'd like to have those emails go to google apps rather than try to be delivered locally.
I know there's a postfix config file for aliases, but here, the email addresses are the same, just need to tell postfix not to try to deliver locally.
Any way to do this?
It sounds like you have two mail servers set up to act as the primary destination for email to your domain: Google Apps and your postfix server. You can't do that because, as you've found, mail sometimes gets delivered to one server and sometimes the other.
Presumably you want Google Apps to be the primary destination. That is, mail for your domain should go to the Google servers, not yours. You will need to re-configure postfix so that it is not the mail server for your domain.
Edit the /etc/postfix/main.cf file and look for the mydestination line. Remove your domain from that line.
I don't normally use postfix, but I think if the line looks like this, you'll be good:
mydestination = $myhostname localhost.$mydomain localhost
Let's say your server name is "test1" and your domain is "example.com." The following addresses would be delivered locally:
info#test1
info#localhost.example.com
info#localhost
But mail to info#example.com would go to Google Apps because postfix is not configured to accept mail for simply "example.com."
I get around it by doing this http://souptonuts.sourceforge.net/postfix_tutorial.html. Basically have that mail sent through one of your google domain accounts instead of locally.
Either, as Barry Brown suggested, tell postfix that my-domain.com is not local by removing it from $mydestination on the postfix box, or if that's not practical, use virtual aliases in Postfix to rewrite that specific address (info#my-domain.com) to the google-hosted address you want to deliver it to.
Virtual aliases in Postfix are not just for the virtual alias address class; they are a general-purpose pre-queue address rewriting mechanism. Sendmail-style aliases (depending on your distribution, either /etc/aliases or /etc/postfix/aliases) are used by the local delivery agent and only apply to the local address class. You could, of course, use sendmail-style aliases to forward mail for "info" to some-address#your-google-hosted-domain.
The documentation at postfix.org is pretty good. Try
http://www.postfix.org/STANDARD_CONFIGURATION_README.html
http://www.postfix.org/ADDRESS_CLASS_README.html
http://www.postfix.org/ADDRESS_REWRITING_README.html
http://www.postfix.org/VIRTUAL_README.html