We want to provide a Gmail integration to help users find out all bounced emails. What will be the best way to do it? A user sent an email to xxxx#thiswillbounce.com and then got back a bounced email from the email server. From the gmail API, we can see bunch of headers from the bounced email. Can we use these headers to detect this is a bounced email programmatically?
Bounced email's headers:
{
"name": "Subject",
"value": "Undeliverable: Test Mail"
},
{
"name": "From",
"value": "Microsoft Outlook <MicrosoftExchange329e71ec88ae4615bbc36ab6ce41109e#outlook.com>"
}
...
You can use Gmail Search to detected bounced emails and they mostly have mailer-daemon as the sender.
from:(mailer-daemon#google.com OR mailer-daemon#googlemail.com)
You can then parse the plain text part of the raw message to detect the original recipient where the message was sent to.
I also wrote a tutorial on detecting bounced emails in Gmail with Google Scripts.
Related
When a user unsubscribes from an email in gmail, it seems gmail sends an email to the sender with:
`subject`: "unsubscribe"
`body`: "This message was automatically generated by Gmail."
`to`: u+(somesuperlongrandomstring)#domain.tld
`from`: (Email of user who unsubscribed)
Similarly, when a user unsubscribes from an email in Apple Mail, it seems Apple Mail sends an email to the sender with:
`subject`: (blank)
`body`: Apple Mail sent this email to unsubscribe from the message "(Subject of email unsubscribed from)".
`to`: u+(somesuperlongrandomstring)#domain.tld
`from`: Email of user who unsubscribed
We use mailgun to handle unsubscribes already, but as of 28th March 2022, these emails from both providers now make it through our email routing.
Does anyone know how to tell gmail or Apple Mail to not send these emails? They are redundant because mailgun is already handling the unsubscribe using the list-unsubscribe header as you'd expect.
Alternatively, does anyone know how to set up Mailgun so these messages aren't passed through routes?
So Mailgun didn't provide any help, sadly. But looking through their documentation, and the headers of these emails, it seems possible to use their Routes to hide the emails completely.
The three clues are:
Emails always coming in the format u+(...)#domain.tld
Gmail unsubscribes always have the subject "unsubscribe"
Apple Mail unsubscribes always have the header: X-Apple-Unsubscribe:true
As such, you can create a route as such to capture and discard these emails using a custom route with the raw expression set to:
match_recipient("u\+(.*)#domain.tld") and (match_header("X-Apple-Unsubscribe", "true") or match_header('subject', 'unsubscribe'))
It's sad that Mailgun stopped doing this themselves, but at least there is a solution with their tooling!
I am using sendgrid to send out emails. My Django code for sending emails looks something like this
client_message = EmailMessage(
'Subject',
'Message Content',
'Name <support#domain.org>',
[client_email],
['support#domain.org],
)
client_message.content_subtype = "html"
client_message.attach('MyFile.pdf', file, 'application/pdf')
client_message.send(fail_silently=False)
I have the content_subtype as HTML so that I can do page breaks between paragraphs.
I am sending out 2 emails at a time and am sending a very low volume, < 100 / day. I just began sending emails. My emails are landing in Gmail spam inbox and not getting delivered at all into Yahoo / Comcast. I have already whitelisted my own domain's DNS using SendGrid.
What is best policy for my email content so get them delivered? I have heard
Removing all hyperlinks in my message
Putting a physical mailing address in the footer of the email
Putting the words "reply STOP to unsubscribe" in the email footer
Changing the content type of my email from HTML
It's important that I attach the files when sending the email. What else can I do to make sure my emails go through?
I had just verified my domain a few hours before sending the ultimately deferred emails. I believe the answer is that my domain verification was still being processed, and my emails landed in the the recipients inbox 2 days later. For future people having this problem, if possible see if the problem fixes itself after a few days.
Litmus.com is also a fantastic resource to check your content and security settings.
i am facing a problem when i send email using cakephp3 on my hosting. Emails are being sent but when i view the recieved email in browser i see this along with the email address from i'm sending the email
From: no-reply#mail.com via cp-in-12.webhostbox.net
However when i check mail in phone's gmail client 'via cp-in-12.webhostbox.net' does not shows up.
Here is my code
$email = new Email('default');
$email->from(['no-reply#mail.com' => 'no-reply#mail.com'])
->to('mymail#gmail.com')
->subject('Test Mail')
->send('Thank You! for purchase! its a test mail');
}
Please help.
Thank You
Google appends the "via mail.domain.com" when the sending domain does not have any sort of SPF records on it. It's to notify users that the email may not have originated from the "From" email address' domain, but since you don't have any restrictions (set by SPF), Google can't tell if you're a bad guy, or just haven't set up your records yet. You're going to want to either setup some SPF and DKIM records (check with your webhost on how to do that), and that should eliminate those messages. The reason it doesn't appear on iPhone is because that platform does not have that feature.
We have an app that sends emails on behalf of our clients. All emails are sent via Sendgrid. As part of this we have verified our email sending domains via DKIM and SPF.
When our clients send email, it is constructed as follows:
from: Tom Smith <email-service#ourserver.com>
reply-to: tom.smith#email.com
This works in the vast majority of cases, but there are situations where the "reply-to" is not being respected - recipients are clicking "Reply" in their email clients and the reply is coming back to us.
Is there something that we are missing here. Do we need to explicitly set a FROM or SENDER header? Or something else?
I Know the below things
To: is to the person who is receiving the email or taking action regarding email received
CC: is "Carbon Copy" which basically is for information so that they know the "To" person recieved the email and the action should be taken on the mail received
BCC: Blind Carbon Copy meaning that the others who recieved the email will not know that the BCC person got the email.
But My actual doubt is that,
Yahoo is blocking the mails received by there user, send using third party tools/servers. Here is more info from Yahoo
When a send a mail from some site in the below format
From: xxx#yahoo.com
To : yyy#yahoo.com
Sender is receiving error message.
But if i send in below format yahoo is accepting mails
Edit
From: xxx#yahoo.com
To : zzz#gmail.com
CC : yyy#yahoo.com
The error you mention is purely caused by a policy with Yahoo that states, from the link you give,
Your message wasn't delivered because Yahoo was unable to verify that
it came from a legitimate email sender.
So Yahoo's concern is to make sure spam is not sent using forged addresses unknowingly to the legitimate address owner.
If you include the CC field with the same address as From, it means at least the "maybe forged" sender is receiving a copy of the sent email. And that seems to be sufficient for Yahoo to accept to forward your email.