Is it possible to create a correct SPF and DMARC DNS record when you use a CNAME? - heroku

In my setup I have a website (example.app) hosted on Heroku.
Then, I use Sendgrid to send emails from the Heroku server to our users that forget their password. The email is registered using Google's Gsuite. So I also send emails from the Google servers.
The from email is: <Appname <noreply#example.app>
So I thought these should be my DNS records (note I don't have an A-record):
CNAMES:
example.app CNAME "example.app.herokudns.com"
www.example.app CNAME "www.example.app.herokudns.com"
SPF:
example.app TXT "v=spf1 a include:_spf.google.com include:sendgrid.net ~all"
Dmarc:
_dmarc TXT v=DMARC1; p=none; rua=mailto:dmarc#example.app; ruf=mailto:dmarc-forensic#example.app; fo=0; adkim=r; aspf=r; rf=afrf; pct=100; ri=86400; sp=none
However, the Dmarc record doesn't validate as mail is send from a different domain then the To address. I think the email is send from sendgrid.com and the to-address is example.app.
Hence, I think by adding the IP-addresses of my Heroku DNS into the SPF record it should work.
But how do I do this, when these IP-addresses are dynamic?

"No" by protocol - rfc1912#section-2.4 but "yes" if using CNAME flattening.
Also, you should configure your SPF and DMARC using your email servers, in your case, sendgrid not your#example.app
Check more about how Cloudflare deals with CNAME flattening here: https://blog.cloudflare.com/introducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root/

Related

Laravel Mailgun : Emails accepted but not delivered for addresses with the same domain

I have a domain https://magicamaids.com and a sub domain related to it is mailing.magicamaids.com. I configured mailgun with sub domain DNS. All TXT, MX, CNAME showing verified.
But I can't send email to anyuser#magicamaids.com from no-reply#magicamaids.com. But I can send email to any other gmail or outlook mail account from no-reply#magicamaids.com.
Note: Basically i have a contact-us form submission page. and i need to send email to sales#magicamaids.com. Here is my code
Mail::to(['sales#magicamaids.com'])->send(new ContactUs($data));
My .env file is
MAIL_FROM_ADDRESS=no-reply#magicamaids.com
MAIL_FROM_NAME="${APP_NAME}"
MAILGUN_DOMAIN=mailing.magicamaids.com
MAILGUN_SECRET=4a6ec.....
MAILGUN_ENDPOINT=api.eu.mailgun.net

DNS record validation using sendgrid with Domain.com

I have been unable to find any help of almost any kind for Domain.com.
I am trying to set up SendGrid domain authentication. All I get is errors.
SendGrid side:
Failed
Expected CNAME for "em.....[mywebsite].com" to match "..........sendgrid.net".
Expected CNAME for "s1._domainkey.[mywebsite].com" to match "s1.domainkey.........sendgrid.net".
Expected CNAME for "s2._domainkey.[mywebsite].com" to match "s2.domainkey...........sendgrid.net".
On the Domain.com side I set it up like this:
**Record** **Name** **Content**
CNAME em.... ..........sendgrid.net
CNAME s1._domainkey s1.domainkey...........sendgrid.net
CNAME s2._domainkey s2.domainkey...........sendgrid.net
Does anyone know what I am doing wrong?
Twilio SendGrid developer evangelist here.
If you lookup the DNS records for your domain you will see that there are no listed CNAME records. However, you will also see that your name servers are listed with Digital Ocean. So, making the changes in domain.com will not make a difference to your domain as they no longer control the name servers.
I recommend you log into Digital Ocean and set up the CNAME records for your domain there. Then you'll be well on your way to setting up your Domain Authentication with SendGrid.

Sending email with Mailgun account I got the domain is unverified and requires DNS configuration error

My Laravel 8 app is located at tads.my-demo-apps.tk as a subdomain of my-demo-apps.tk.
This domain is created at https://my.freenom.com/ with Ubunutu 10 installed on ubuntu 18
When I send an email with my yahoo.com account(under which I enter into the main dashboard)
I got the email, ok, but I see not rendered HTML code in the content of the received email.
I try to send an email to my Gmail account I got the error:
{"message":"Expected response code 354 but got code \"421\", with message \"421 Domain my-demo-apps.tk is not allowed to send: The domain is unverified and requires DNS configuration. Log in to your control panel to view required DNS records.\r\n\"","user_id":2}
Opening the DNS page of my domain, I see: https://imgur.com/a/QJBJgWn
But I am not sure which records have I to check and how?
In details of my new Mailgun account, I see
Plan Flex
Emails sent 3 of 1.3K
Validations 0 of 0
Dedicated IPs 0 of 0
Log retention 5 days
Thanks!
You must fill in the DNS records of the domain according to what mailgun asks you.
For example mg.mydomain.com MX Record, etc.
If you don't have access to modify the DNS Records, ask your DNS Provider about it.

Laravel mail on shared hosting

I've a form contact on my website and I want the form to be sent via email when submitted.
I've tried it in xampp and it's working fine.
On shared hosting, it does not work.
I'm using my own custom domain smtp.
Someone can explain me why it's not working ?
Your shared hosting probably blocks outgoing SMTP connections. Many hosting providers do that to prevent spam. You can try using a HTTP/WEB API instead of SMTP to send email.
Some email APIs like Flute Mail allow you to set up an HTTP API connection which can immediately forward the request through your "custom domain smtp" server. So you can keep using your custom domain email server, but get an API for it.
Otherwise you'll have to set up a Web API yourself with an open source tool like Postal.
In your laravel .env file if add following parameters mentioned below and create a e-mail on your shared hosting and add username, password and host of your hosting.
MAIL_DRIVER=smtp
MAIL_HOST=shared_host_name
MAIL_PORT=587
MAIL_USERNAME=mail#sharedhost.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I suppose then it would work fine.

Namecheap SPF record setup for SparkPost not working

I'm having trouble getting SparkPost SPF record setup correctly with my Namecheap domain.
I have the type set as TXT, host set as #, and the value set as v=spf1 include:sparkpostmail.com ~all and TTL set to 1min for quick testing and my TXT record but it still wont work. The TXT record is not propagating using this website to test. https://www.whatsmydns.net/#TXT
In namecheap, I have tried setting my "MAIL SETTINGS" to "email forwarding", no email service, and private email, cause I wasn't sure which mail settings to use either.
Turns out my problem was I had a CNAME record for the # root domain.
From Support:
In case you have a CNAME record configured for # (root domain), email will not work technically. The CNAME has the highest priority and suppresses all other records for the hostname (including MX Records which are responsible for mail delivery). The main difference between CNAME and ALIAS records is that the ALIAS record does not suppress A, MX, TXT, CAA records for the same host, unlike the CNAME record. In this case, I advise you to change the host type from CNAME # xxx.herokudns.com. to ALIAS # xxx.herokudns.com.
Looking at the heroku docs, it also apears they recommend using the ALIAS for namecheap.

Resources