SendGrid send mail - how to keep track of emails? - sendgrid

I am sending emails from sendgrid from my backend. When I send the email, the response is 202 and the response body is empty. Since the response body is empty, i do not have any information like an ID to track the email events in my system.
When I go to fetch the events, i see they have an ID, but since I don't have that ID from their creation, I cant map emails I sent to events I received.
Can you give an email an ID or label it somehow when you send it? So that you can map al the events from it?
What we are trying to do is to have a list of "transactions" where each "Transaction" is affiliated with an email. We want to provide email event data in our app, but can't figure out how to map

The response body of a successful Mail Send API call is empty, but the response contains a x-message-id header which you can use to retrieve details about the messages being sent.
Since one API call to the Mail Send API can result in multiple emails being sent, this ID identifies the group of messages, and they'll all be prefixed with the x-message-id. For example, if x-message-id returns W86EgYT6SQKk0lRflfLRsA, the IDs of your messages will start with that and then be suffixed with something like .filterdrecv-5645d9c87f-78xgx-1-62841247-82.1.
Together it'd look like W86EgYT6SQKk0lRflfLRsA.filterdrecv-5645d9c87f-78xgx-1-62841247-82.1.
If you want to track the messages, you can use the event webhook or pull the information via the Email Activity Feed API.
This Stack Overflow Q&A about tracking bulk email statuses may also be useful to look at.

Related

Automatically triggering an action on your backend from an incoming email message

Platforms like upwork have a feature where when you get a message through those platforms, you also get an email.
Instead of logging Upwork to reply, the user can simply reply to the incoming email, and the message is then automatically sent by upworks backend to the original person who sent the message.
How exactly is this done in a way that Upwork knows the inbox to send the message to, and is able to receive a message via email.
It seems Upwork handles incoming emails by detecting any project ID in the email message - it can be an ID in the subject or in the email body and etc. So, the email can be recognized easily and processed. Also additional information can be checked on the incoming email - the sender (whom the original emails was sent out), the recipient and etc. Actually, it is up to your needs how algorithm should be working.

How to track status of email in sendgrid without using SMTP.

I want to send emails which contain different contents to same user and I need to track their status. Are there any way to do that without using SMTP.
Sounds like you want Unique Args. These are called custom_args in the v3 API mail send argument, but it's the same concept.
Once you activate the Event Webhook, all events will include the appropriate unique_args, so you can relate each specific message to each.
Also, whenever you send a message to SendGrid, the acceptange response includes a message_id, which will be in all those events.

Identify email message related to received webhook

Today I started to learn about webhooks and I was wondering if it is possible to know exactly what message is related to a received webhook.
For example, I have a website where customers can register and, after a successful registration, I'm sending them a confirmation via email. Is it possible to know that the customer clicked on that specific email message? (Considering that the customer can receive other types of email messages like password recovery, newsletters, etc). I know I can use the subject (something like if subject == 'Welcome to My Site' then do-email-post-registration-clicked-routine) but if the subject changes, or if they change it (when we reply to a message, usually the email client prepends "Re:" to the subject, I won't be able to track it.
Thanks in advance!
Yes. You can use custom arguments to track individual emails. Custom arguments get sent with event webhooks.
More documentation can be found here: https://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html

Check if an email address is already in a list using MailChimp API v3.0 without subscribing the email address

Is it possible to check whether the email is already in a list or not via the new MailChimp API v3.0?
I know I can make a post request to the lists/{list_id}/members/ endpoint that returns a 400 Bad Request error if the email is in the list.
This is ok and it helps, but it does subscribe the email as well if it is not in there already.
My main goal is not to subscribe just to check.
The ID of the user is the MD5 hash of their email address. So make a call to /3.0/lists/<list_id>/members/<email_md5> -- if that returns a 404, the user isn't on your list. If you get a 200, the resulting object has a status field that will tell you whether the user is subscribed or not.

How to send bulk emails with different subjects using Mandrill API?

How am I supposed to do to send bulk emails with dynamics subjects?
For example, If I need to send 200 emails at once, I don't want to call the Mandrill send() method 200 times because I suppose it's a very bad practice.
I'd want to call the send() method 1 time, putting my 200 recipients in the to attribute (this works well). However, in that case, how to set a different mail subject for each mail sent?
Thanks.
You can use merge tags within your subject to change the subject line for each user.
http://help.mandrill.com/entries/28499087-Can-I-use-merge-tags-in-my-subject-line-or-other-headers-
You can provide a default value for your merge tag and/or for each/some users personalised data.
Given the anatomy of an e-mail in Mandril is based upon subject and body (or template) to define a unique entity what you are asking to do isn't possible. A different subject or body constitutes a different e-mail and requires it's own .send().
If the same e-mail (same subject and body/template) was being sent to all receipts then a single .send() would work.