Send and receive email by Rails App - ruby-on-rails

We have build custom crm app(rails 4.0). One of the features that we have build is that we send emails to our customers based on booking status or we send a custom email by our travel agents.
The next thing we want is that customers can replt on this email. So we can recognize the email thats replyed and related to the initial email is send, so we have a nice email dialog (send/receive) in the crm.
Someone ideas how we can "recognize" the replyed email so we can related it to the right email?
Thanks..remco

In your email client open a reply from someone and show full headers or raw source (how to get it depends on the client but you will find it!)
When you look at the email headers you will find References field
References: <CAAC3oDjZSFywS5mpAANO+svm-3xXwLciUhw_QEkBkNqT9A#mail.com>
<06AFEF94-53D2-4469-59B0A494830C#mail.de>
<E67E3945-D61E-8E45-63C52D111698#mail.net>
And more importantly
In-Reply-To: <6397034C-90CA-41B4-F47AE3F39E76#mail.de>
While every outgoing email has a Message-ID field
Message-ID: <569F22.8060202#mail.de>
To get an if of you outgoing message
result = SomeMailer.message(params).deliver
result.header['Message-ID'].value

Related

MSGraph - Getting external email conversation from reply

My team is building a ticketing system. The goal is when we receive a new email we create a new ticket. All responses to that email are saved on the same ticket.
We have these basic goals working in simple cases, however, there is one case that we are struggling to find a good solution for. A client will email us, which creates a ticket, and we reply back requiring information. The client will send our reply to someone internal to their company. Then they will send the response back to us by replying with "see below". This response will have the conversation between them and their co-worker in the comment section of the email. The comment section will also contain our entire email chain which we don't want to duplicate.
The issue we are having is grabbing the conversation they had from the comment section to include with their response of "see below" and add them to the ticket. The only method we have come up with to solve this is manually parsing the comment section of the email, however, this is error-prone.
Does anyone know of a better way of tracking conversations they send you through the email?
We are using msgraph internally to send and receive emails and using their apis they have uniqueBody and body, but they don't seem to have a way to break the body up into its different parts.
What I need any of these options
1- get list of unique bodies from the email chain without using conversation Id as it will not be sufficient in some cases.
2- get the previous conversation Id of the incoming email. I mean if that email is a list of emails and it forwards to me.
UUID uuid = UUID.randomUUID();
message.addProperty("InternetMessageId", String.format("%s",uuid.toString()));
send InternetMessageId with a unique identifier to grab conversation id
change order only

How to auto reply of a Gmail emails

Here am using gmail and streak with zapier. And my problem is as:
How can I automatically reply to the incoming emails using zapier.
when anyone send me any email my current configuration send a thanks mail to that sender but to it reply.
Here I want to reply on all emails automatically.
Please help me soon.
David here, from the Zapier Platform team. I haven't used Streak CRM before, but it sounds like you want to send an email every time a new box is created? If so, the following template will do just that:
https://zapier.com/apps/gmail/integrations/streak/3574/get-gmail-emails-from-new-boxes-in-streak

Rails and email openened notifications

I am developing an application on Rails and I need to know if its possible to write code which will notify me when the user opens an email that has been sent from my application (need to track this info) ?
The main bit of data I need is was it opened.
thanks
You can do this but there is no 100% certainty you will always get a notification.
SMTP has 2 standards, they are DSN and MDN. Both are in effect optional, there is no guarantee that the email system of the targeted email recipient (your user) will implement them too.
The easiest way is to pit in a "Return-Receipt-To:" (RRT) email header. Put some address as the content of the header. Now when a user opens an email message containing this header, the clients email reader will msot likely prompt your users whether or not to send a return receipt. If the do comply and email will be sent to the address you specified.
In Rails it could be something like:
themailer < ActionMailer::Base
def notify_read
headers['Return-Receipt-To:'] = 'notifyread#mysite.com'
mail(:to => 'users#somecompany.com')
end
end
You could just use an email address you monitor and read them manually OR you could set up rails to read these emails as well. But there is no guarantee you will ALWAYS get an acknowledgment.
Additionally you could check each email domain, many of the big free email providers have proprietary methods of requesting the return receipt. If you add ".readnotify.com" onto the end of your recipients email address you will get a return receipt. You will have to research all the big ones though.
For example:
user#yahoo.com.readnotify.com
Hope that helps
Source: http://railsforum.com/viewtopic.php?pid=147997#p147997
A common way of implenting this is to include a link to an invisible image file, with the link including sufficient details about the email for you to be able to identify which email is being viewed.
When the image is requested by the mail client, your server can then record the viewing attempt. If you use a 3rd party email provider (such as sendgrid, postageapp) then sometimes they'll do that for you and ping your server with the appropriate event. I strongly suspect that this is what readnotify is doing under the hood (someone took the trouble of looking at this a while ago
This isn't completely accurate as some (many?) users turn off remote image viewing in their mail viewers.

Jenkins Extended Email Notification - Email Content as attachment

Using Jenkins 1.499 and version 2.25 of the Jenkins Email Extension Plugin. When emails get sent, the content of the email is showing up as an attachment to the notification and not in the body of the email. In fact, the body of the email is blank. Changing the content type of the email has no effect. We use Exchange/Outlook, could that be the issue? Any ideas to get the content of the email in the body of the message?
I think this may have to do with your junkmail settings, either in Exchange and/or in Outlook
For me, when I received the first Jenkins email in Outlook, I had to click on the warning lines (just above the email header) and select "Add sender to safe senders list"

How can I integrate internal messaging with emails in asp.net?

in github when a user sends you a message two things happen. You get a "new Message" on your github dashboard and you receive an email.
if you reply to that email it triggers a new Github message internally... so the users can actually have a full conversation through their email client without going into github even though Github is managing it all.
I know Malgun/Sendgrid have apis to manage receiving of emails (they send a POST request to your app when an email is received) but I need a little more info on how to do it... how exactly can I set up my app so that when a user receives a message they can just hit reply on their favorite email client while still maintaining track of that conversation. (they can still check their messaging history through my site)
Does anyone have an idea how exactly they do it?
Please help.
How this is implemented really depends on how you can handle incoming messages. If you're able to receive your emails as a POST to your application, then the email is really no different to a user sending the message on your site, you just need to parse the From: header from the email, and look up the user, and strip the fluff out of the email.
If you're writing your own code to handle the emails (eg. that polls a mailbox), then you could just POST them over to your app in the same way, or parse them up and POST more structured data.
Once you have the data, it's easy to construct a message and write it to your DB (and fire off email notification to the user, remembering to set the Reply-To: or From: headers so your script gets the replies). Most of these kind of messaging systems don't keep track of conversations/threads, but just store a string subject (and use "Re: ...") to keep things simple, though you could obviously add this if you're feeling ambitious!
If you're doing this, you should be security in mind - malicious users may POST to your email script, and email headers can easily be forged. Spammers will also use any possible scripts they can find to relay mail through other peoples servers.

Resources