How do I alternate domains for sending emails for my app running on Heroku with Sengrid Add-on? - ruby-on-rails

So we are running a rails app on Heroku with the Sengrid add-on (free plan so no whitelabeling) (let's call it magicapp) and in our action mailer we always set the from field to be "noreply#magicapp.com". We have seen some of our email go to spam and someone suggested to us to try to alternate our email domain to improve deliverability.
So my questions are as follows:
What verification and checking goes on at the receiver side to verify that the email really is sent from "magicapp" and not just someone pretending to be magicapp?
Right now, when we send an email from "noreply#magicapp.com" the email says it's from "noreply#magicapp.com via sendgrid.me" so when receiver clients are doing spam checking, do they use my "magicapp.com" domain for reputation or the "sengrid" domain?
If it does use the "magicapp.com" domain, could I just set my from field in my action mailer to be a different domain such as "magicapp-mail.com"? Are there any potential issues to this or additional things to set up, like DNS etc? If I do this, will the receiver use the reputation of the magicapp-mail domain instead of magicapp then?
Any answers or information would be much appreciated, thanks!

I am pretty sure setting sendgrid's DKIM and SPF records properly will save your emails from being sent to spam. At least that's what worked in my app I was working on and emails ended in inbox, unless users hit Mark as spam instead of unsubscribe.
DKIM
DKIM stands for DomainKeys Identified Mail which was designed to help ISPs prevent malicious email senders by validating email from specific domains.
What a basic DKIM record should look like:
smtpapi._domainkey.yourdomain.com. | TXT or CNAME | value
smtpapi._domainkey.subdomain.yourdomain.com. | TXT or CNAME | value
TXT value: k=rsa; t=s; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPtW5iwpXVPiH5FzJ7Nrl8USzuY9zqqzjE0D1r04xDN6qwziDnmgcFNNfMewVKN2D1O+2J9N14hRprzByFwfQW76yojh54Xu3uSbQ3JP0A7k8o8GutRF8zbFUA8n0ZH2y0cIEjMliXY4W4LwPA7m4q0ObmvSjhd63O9d8z1XkUBwIDAQAB
CNAME value: dkim.sendgrid.net
docs: https://sendgrid.com/docs/Glossary/dkim.html
SPF
Sender Policy Framework (SPF) is an email authentication standard developed by AOL that compares the email sender’s actual IP address to a list of IP addresses authorized to send mail from that domain. The IP list is published in the domain’s DNS record.
The DNS record should look like this:
yourdomain.com. | TXT | v=spf1 a mx include:sendgrid.net ~all
docs: https://sendgrid.com/docs/Glossary/spf.html

The key is your 2nd question. As long as you're not whitelabeled, the receiving server 'knows' the mail came from SendGrid, so it checks SendGrid for all DKIM & SPF records. SendGrid signs your mail with their own DKIM if you're not whitelabeled, so it all checks through.
"Alternating" the domain does not sound like a feasible way to avoid bulking of your mail. We're still in an IPv4 world, and IPs are still the main source of reputation tracking in the email world. No matter what domain your mail says it's "From", the receiving server knows what IPs gave it the mail (unless your domain is so bad it's blacklisted).
What does mail-tester.com say about your mail?

Related

Subdomains in Mandrill

I am using Mandrill trial account for sending emails, i have a question which i am not able to find a solution.
I have a domain (www.domain.com) which is registered with Mandrill account with an email address email1#domain.com. I have a requirement where i have to sent emails from different sub domains from mandrill. Is there any facility to configure sub domains or wildcard DNS in Mandrill. Basically i want to sent email from different email addresses like email1#subdomain1.domain.com, email2#subdomain2.domain.com, email3#subdomain3.domain.com.
Here the sub domains can be anything which changes for different users, but the main domain doesn't change. Is there ant way to achieve this.
Please help me, I am new to Mandrill.
Since you own the domain and thus also the email server,
go to your email settings
forward/reroute email2#subdomain2.domain.com to email2#domain.com
receive verification link on email2#domain.com
verify and use the application

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.

Emails sent from postfix via a Rails app are getting sent to spam in gmail

When using 'mail' command to send email to a gmail user, the email goes through fine. When sending an email using a Rails app, the email is sent to the spam folder for the gmail user. Can someone help me think through this?
Emails landing in SPAM can happen due to many reasons:
Wrong Mail Server setup: Checkout here on how to setup
Email content: Content of the email can also invite SPAM. Sites like SpamCheck helps to check whether the content of the email is ok.
As mentioned by #Noli above, using services like Sendgrid, Critsend etc for sending out emails, chances of landing them in Inbox will be more. You can use them as relay servers from Postfix. But the first two steps are anyway necessary.
Use Mailchimp if you want to sent emails to many people, for eg: for sending out newsletters, marketing emails etc.
Mail deliverabillty is extraordinarily hard to get right. You should consider leaving this to the specialists like Sendgrid or Mailchimp, and not spend tooooo much development time thinking about it
Another thing to check is that if this is a new server, you may need to set up Domain Keys to authenticate to Gmail. This happend to me and I was able to get my mail removed from the spam folder by following these:
https://help.ubuntu.com/community/Postfix/DomainKeys
https://help.ubuntu.com/community/Postfix/DKIM

Most reliable way to deliver emails from a users email address in rails?

I would like to allow users to send emails which are generated in my rails app from their email address .
I know I can just use my servers sendmail, and set the from address to their email address, but there is a high chance the emails will be marked as spam.
Is there a better way to do this? Can I use sendgrid, or Amazon SES or make the user input their own SMTP details.
Any suggestions or best practices would be much appreciated.
This will fail in the face of SPF. SPF is essentially a way for a domain to say "email purporting to be from this domain will only be sent from these servers", so if you send email from a user at that domain from your server, anyone who does an SPF-check is likely to mark your mail as spam.
Essentially: Don't use the From header if the mail's not from the sender, use the Sender header instead.
I believe SendGrid support customising the From address. Heroku provide them as an add-on and they advertise "Complete control over the From: address." on their add-ons page
Amazon SES is out of the question for this use case: they require an authorization procedure before sending as a certain email address.
Even if you prompted them for SMTP server details, that's going to set off huge red flags to any competent users. Most SMTP servers are properly configured to either require authentication during the SMTP transaction, or require a recent POP3 or IMAP connection, and that means gathering user credentials. Do you feel like asking your users to trust you with their email password?
Overall, this is actually an astoundingly bad idea, especially considering email authorship proving techniques like SPF / Sender ID. Mails sent this way through non-authorized servers are increasingly likely to get (rightfully) flagged as spam.
Would your use case allow the mails to be "From" your application, but have a "Reply-To" of the user?

Why won't hotmail let me include a name in addition to my email address?

I'm trying to send emails from my Ruby on Rails application, and whenever I use the following format: Jon Doe <jdoe#mydomain.com>, Hotmail marks the email as spam. However, when I use jdoe#mydomain.com without the name, it goes through fine. Anybody know how to get around this so my emails don't get sent to spam for hotmail users?
I have SPF set up on my DNS and I'm sending from the SPF verified server if that's of any help.
Thanks!
Are you specifying the pretty name in the MAIL FROM or in the header? In the MAIL FROM, you're only supposed to include the mailbox address itself, according to RFC 2821. Most mail servers will tolerate the pretty-from there too, but Hotmail may be using that as a spam signal.

Resources