How can I make a script to automatically get suppressions(Bounce, Spam, Invalid and Block) from SendGrid and send them by email to anyone that I want to? I was considering using SendGrid api but I am not sure if it possible.
You can retrieve a list of bounces, blocks, spam reports and invalid emails via the respective APIs.
You can also use the Event Webhook to receive events about your emails including if an email was dropped, bounced, blocked or reported as spam.
Related
According to the Push Notifications guide within the Gmail API . The Gmail API can notify your back-end server application whenever your Gmail mailbox changes.
To do this, you need to setup a Cloud Pub/Sub client and create a topic. After that, you can then configure your Gmail account to send notifications for mailbox updates. The guide says that
To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, simply use your Gmail API client to call watch() on the Gmail user mailbox similar to any other Gmail API call. To do so, provide the topic name created above and any other options in your watch() request, such as labels to filter on." This quote was taken from the "Getting Gmail mailbox updates
section from the guide linked above. The guide also provides an example of making a watch() request.
My problem is that I need to filter by sender, not label. I am creating a bot that is going to be deployed to a hosting provider, probably GCP.
I am basically looking for a way to get the Gmail API to notify the bot whenever I get an email from a certain sender. I looked at the watch method in the docs and it seems like the only possible filter is label.
So is there an alternative way to get a notification via the Gmail API whenever I get an email from a certain sender?
Update:
Oh ok, so I was reading about publishing messages to topics via the Pub/Sub API, and according to the description of watch in the Gmail API docs, it seems like watch is responsible for getting Gmail to send (or publish) notifications to the topic. The Subscriber overview section of the Pub/Sub API docs say that
To receive messages published to a topic, you must create a subscription to that topic. The subscription connects the topic to a subscriber application that receives and processes messages published to the topic."
So the subscriber application would be the bot. According to the Filtering messages section of the Pub/Sub API docs, you can create a subscription with a filter. It says
"When you receive messages from a subscription with a filter, you only receive the messages that match the filter. The Pub/Sub service automatically acknowledges the messages that don't match the filter. You can filter messages by their attributes."
So, do the messages (or notifications) that Gmail is sending (or publishing) to the topic include a "Sender" attribute? I can't seem to find the attributes that Gmail includes in a notification message...
No attributes are populated by default
See this example notification structure here: https://developers.google.com/gmail/api/guides/push. As outlined in the spec, it's permissible for attributes to be empty so long as data is populated, which it is for Gmail API notifications.
So the answer to your question - if you cannot find the "Sender" attribute - this is because the message does not contain any.
I'm using django-sendgrid-v5 and I read somewhere that it isn't good to send emails from the main webserver. Should I process emails from Celery? Or is it fine to call from the main app since I'm using an external service like Sendgrid anyways?
I don't know in which context you've read that, but I would guess it has something to do with reliability, spam and security in general.
Short answer: Yes, this should be fully okay as you are using an external email service.
Another option is to set up a Smart host on your webserver and let your main email server deliver it to the final recipients.
Long answer: Nowadays sending emails from a (web)server, which is not fully set up as an email server might be difficult in means of reliably sending emails.
Due to the massive amounts of spam and malware sent, most (or at least a lot) receiving email servers (Mail Exchangers) are trying to check if the emails they should deliver to their users, are legit.
This is done by several settings mostly on the server itself. To name only a few: RDNS, DKIM, Greylisting, etc.
In general a (web) server whos main purpose is not sending emails, does not have all these settings. This might result in difficulties to reach certain email addresses.
I'm building an CRM and I have included email within it. When I send out an email from my CRM to a gmail account and then reply to it from the gmail account it automatically threads the conversation (within Gmail), however if I then reply to the reply from my CRM it starts a new thread within Gmail.
I read https://webapps.stackexchange.com/questions/965/how-does-gmail-decide-to-thread-email-messages which states the it is based on the email subject but this doesn't seem to be working a per my issue.
Bearing in mind, when I say I am 'replying' I simply mean I am sending another email with the same subject (to and from the same emails obviously).
The weird thing is, if I send out another email from my CRM with the same subject to the same email it does thread that, just not the reply.
Anyone know why this is happening and how I can fix it?
UPDATE:
Probably worth mentioning, I am parsing the replies, so the previous email bodies are not included.
Threading based on subject isn't standard. You should set in-reply-to header to message-id of first email.
I am setting up a GAE app that triggers certain tasks by an email from the user. I've set up the app using the information on this page: https://developers.google.com/appengine/docs/python/mail/receivingmail. Everything works as expected, however, I would like to send the emails to a #mydomain.com email address, instead of a #myapp.appspotmail.com email address.
Currently I am using an automatic forward on the email address to get around this, however once this scales I expect to reach the daily limit on forwarded messages at some point (10.000 according to https://support.google.com/a/answer/166852?hl=en).
Is there any way that I can integrate my app with the #mydomain.com email address to prevent this from happening? Or would you know another solution for this issue?
Probably, you should check recently implemented GAE integration with SendGrid, I haven't used it myself (use the same solution you've described with email forwarding), but looks like it can help.
As LA_ mentioned, SendGrid offers a webhook for this. I ended up using MailGun, which has a similar functionality and calls a HTTP POST to my app whenever an email comes in on my #mydomain.com address.
We send email using appengine's python send_mail api.
Is there any way to tell why an email that is sent to only one recipient would be marked as SPAM. This seems to only happen when appengine's python send_mail api sends to Gmail.
In our case we are sending email as one of the administrators of our appengine application.
And the email is a confirmation letter for an order that the user just purchased, so it is definitely NOT SPAM.
Can anyone help with this?
It seems odd because it is only GMail users that seem to be reporting this issue and we are sending from appengine (All Google servers) I love Google but sometimes Google is stricter to itself than to others :)
I've added the spf TXT record to DNS such as "v=spf1 include:_spf.google.com ~all"
(I'm hoping that will help)
I've tried to add a List-Unsubscribe header to the email but it seems app engine python send mail does not support this header.
Thanks,
Ralph
My guess would be that the content of the mail looks "spammy" for Google, but you can do some things that might help you.
I would suggest you, since this is a confirmation mail, add another admin for your app an email like: do-not-reply#domain.com and use that one for the confirmation emails. Add more text to the body and include the unsubscribe links as well, so your users will have the possibility to not receive more email from your app. Maybe you wouldn't like the last part, but you have to give that options to your users, so this email won't be marked as SPAM.