Google App Script GMailApp send email and group them in Conversation - email

I'm quite new to Google App Script and playing around with GmailApp.sendEmail.
When I try to send several Email with the same subjects, how can I make them grouped in one single Conversation (given that the Gmail of receiver has Conversation option turn on).
Many thanks,
Minh

Since you're using GmailApp, take a look at the Gmail Thread Class. If you use thread.replyAll(body, options) to respond to the first message you sent, the second message will appear in the same thread in the receiver's mailbox.
When sending the first message, you would need to cc yourself for it to end up in your own inbox, then you could use [GmailApp.search()][2] to find the threads with messages matching the one you sent. From there, drill down to the thread, and replyAll.

Related

How do email threads/chains work, and how do I ensure sending two emails separately will be merged together in a thread in the users email client?

I'm using AWS SES to send emails to customers. I want to send an initial email to confirm an action they've made on my website, and then send subsequent emails to that same email address to notify of any subsequent activity on that initial action.
Different email clients appear to implement this behaviour differently, and I've read about the thread-index header here, but that doesn't cover all clients.
Is there a standard way to mark that an email belongs to the thread of a previously sent email?
Thanks
When adding the References Header to Emails, you can add message-ids of previously sent emails in order to create email threads.
Of course it's again a topic of the client to fulfill this feature, but it should be supported by major email clients.
Heres an old blogpost about that. (considering that email is also old, it should be fine ;) )
https://wesmorgan.blogspot.com/2012/07/understanding-email-headers-part-ii.html

Forcing new thread in Gmail

We send an automated email whenever someone signs up for our app.
The subject is always the same for every user.
Let's say the subject is 'Welcome'.
The problem is that whenever someone replies, it always end up in a single giant thread in gmail.
So the emails from various users are interleaved with each other, which makes it very difficult to manage.
What we want is a single thread per user (i.e per recipient email address) so that we can keep the conversation with each person separate.
I'm aware that gmail has its own way of grouping messages into thread based on the subject line by default.
However, we noticed that some support tools (such as Zendesk) have somehow find a way to keep each email separate even though the same subject line is used. They seem to have a work around.
What I mean is that we have received multiple emails from the Zendesk email sender with the same subject and somehow they end up in multiple threads in our gmail.
They don't seem to use a uniquely generated email either. The from and reply-to address is simply support#domain.com
How do they do it?
We experimented with the 'Message-ID' and 'In-Reply-To' SMTP headers but were unsuccessful.
Sending emails with different Message-ID still end up in the same thread.
See example of a Zendesk email received to my gmail address below:
Since I can't post in the comment, will add to the answer here. Sample headers in an email I received from Zendesk. Note that they use the support email address + the ID of the support ticket as the 'Reply-To' address.

How to prevent the acidentally mail sending in my app?

Too many times i receive mails with no content or with just "Sent from my iPhone". Those mails are sent from the "contact" section in my app.
After a little bit, it became boring.
So, is there any way to prevent the accidentally mail sending? I'm tired to see blank emails!
Don't think one can do much about the empty mails. (Maybe I haven't received so many yet that it troubles me ;) )
On the there hand the benefit of receiving user mail with a contents outweighs the boring empty mails. So I would just put up with the empty mails and maybe create a filter in the email client.
You could use the addresses for a newsletter with info about your app (with an out-out of course)
As you can not send mail through phones mailApp without user pressing the send button you also can't stop it from sending mail. If it really really bothers you you'll have to encode your own SMTP protocol and start sending mail directly from your code. But is it really worth it?
Or you can make user to type the text into a form (textbox) before calling mail-app. If he wrote something you pass it to mail-app and then he must go trough 'send procedure'

Handling undelivered emails using Zend Mail

I'm sending newsletter using Zend Mail. I have used setReturnPath() to put all undelivered mail notifications in one place.
And what now?
How to get the list of addresses which were unreachable?
How do I read and parse the returned notifications?
How to know whether the mail returned because of non existing email or just quota exceeded?
Which headers do I need to send and check?
Related:
Variable Envelope Return Pathwiki
Handling undelivered emails in web appso
This class may be helpful. Can determine whether the mail is a bounce and return a response code with description:
http://www.phpclasses.org/package/2691-PHP-Parse-bounced-e-mail-message-reports.html
Short Answer:
you can't do that in a simple way and not in your app.
Long Answer:
You should handle that in asynchronous way and outside your php app (at least in part). First of all you must setup the return address to something like sender+recipient=recipientdomain.com#senderdomain.com as in the TimB answer. At this point all the notification sent by receiving smtp server will go to that address.
Then you need to setup the smtp daemon at senderdomain.com mail exchanger to handle that kind of bounce messages and process them in some sort of pipe.
With a pipe you can forward the returned message to an external program which parse the message and extract the needed informations (i.e. the reason why the delivery is failed)
At that point in your program (which can be a cli script in your application) you can mark the address as failing and optionally can record why.
This is a pretty difficult task, which can't be handled in a simple application. Usually I use a dedicated software for large mailing list handling such as sympa which takes care of this task for you.
Otherwise you can use an external delivery service such as Sendgrid which will do the dirty job for you and report the failing addresses with a simple API. As a bonus with this solution, they are in the whitelists for all the major providers, so your email won't be marked as spam as far as you respect some simple rules (i.e. removing bouncing addresses and use an opt-in policy for your newsletter)
Well, the second link and especially the answer by TimB explains very well the procedure.
What may not be clear is that the return path is nothing other than a regular email account, i.e. you will get the email to that address. Zend_Mail is not waiting for a response and hence there is no list of addresses.

MFMessageComposer iPhone,Auto Message Send

Any one know how to implement auto send message using MFMessageComposer....i mean No need of displaying The message Composer..we Have to sent the pre-defined message to a given Number..Or any other way without using MFMessageComposer..???
You can't auto-send messages with MFMessageComposer. It always displays the message to the user before sending (and rightly so).
An alternative would be to call a webservice which dispatches an email to you. Or put enough SMTP code in your app to get emails sending. You'll need your own email system for this though as you'll not be able to get the users email settings.