What are the default merge tags in Mandrill? - mandrill

I've searched the Mandrill docs, KB and Google for a list of the merge tags that are always available, but can't seem to find just a simple list for the API option.
I created a template in MailChimp then sent it to Mandrill, but it appears that not all of the merge tags I was using are at my disposal.
From testing it doesn't look like any of the *|LIST:*|* tags work. I've tried *|LIST:PHONE|* and *|LIST:COMPANY|*, but I do know that there are some tags out there because *|CURRENT_YEAR|* works and the docs make reference to using the *|UNSUB:*|* tag.
Is there some hidden docs page I can't find or is there a Mandrill rep that could post them?

In general, none of the MailChimp tags will work because they specifically relate to a MailChimp list or integration, which is not accessible by Mandrill. In general, merge tag values should be provided in the API call or SMTP headers since Mandrill processes those on a per-message basis. As you discovered, there are some that may work, but it's generally best not to rely on that working, and instead provide values for things you want to merge in. Right now, the year will work, as will the DATE tag. Others to note:
*|EMAIL|* will pull in the recipient's email address unless you provide a different value for that merge tag in the API call or SMTP headers.
If you use *|FNAME|* or *|LNAME|* and don't provide recipient values for the one you're using, we'll attempt to parse the name parameter from the recipient list (the to array) to get the recipient's first or last name. That's fairly basic, though, so if you want to include them, it's best to actually define them.

Related

Ruby on Rails. Using Google Client API to parse emails

I am new to Ruby and have a question about how to do a specific task on Rails.
I have a list of inventory and each item has a specific Stock ID that is emailed to my personal Gmail account. I want my web application to listen for emails from a specific email account. When my gmail receives an email from that specific account I want my application to parse it for a couple of fields and insert the stock ID into my database.
For example:
Let's say my database has an item with style code: A5U31 and size:10.
The email will say something like item with style code: A5U31 and size:10 has Stock ID:329193020.
I want my Rails application to search the database for an entry with that specific style code and size, and when it finds an entry to simply insert the stock ID into the row.
I am trying to using the Google-API-Client gem to this, but I am struggling, because I am still a beginner. So far I have done this quick-start guide to authenticate my gmail account with my rails app.
https://developers.google.com/gmail/api/quickstart/ruby?authuser=2
If someone could help me figure out how to write this sort of code and where to put it in my app(models, controllers, views) that would be very appreciated. Thanks!
I know it's been several months since you posted this, so you probably already have it worked out, but in case you still need a solution (or if someone else wants to do something similar), I'll share my thoughts:
At a high level, it sounds like your plan is
Identify when a new email has come in (either by polling or by using a push notification).
Grab the new email's content.
Parse the email's content in order to extract relevant data.
Use the data to query and update a database.
Based on the documentation for the Gmail API, it does look like you should be able to set up push notifications, so you won't have to poll the endpoint to get the information you need.
However, my big takeaway from this list is that none of the items on it really require Rails, since you're not exposing an external web API for requests. I suppose that you could leverage ActiveRecord to create an item model and use that to manage the database; however, since it seems like you'd only need to make some basic SQL queries (and the same ones each time), I'm not sure that bringing in ActiveRecord adds much value.
If I were trying to solve this problem myself, I would probably create a simple Ruby program that (a) uses the gem you mentioned to handle push notifications from the Gmail API, and (b) uses another gem to connect to whatever kind of database you're using (e.g. pg for Postgres) and make the necessary queries.
(All of this assumes, of course, that you aren't specifically using Rails for some other reason, e.g. adding this feature to an existing Rails application).

Mandrill personalized message to recipients with same email

In a NodeJs app I'm using Mandrill to send email reminders to people signed up to different kind of events. Every five minutes the app check for ready reminders and send these. The number or reminders can vary from zero to many at every check.
But here comes the problems:
If for example 3 ready reminder are found at a certain check, and two of these have the same recipient (same email), but different merge_vars because they are about different events. When sent only one (the first found?) set of merge_vars will be used to both of these recipients.
So, how do I keep unique merge_vars even to multiple recipients with the same email? I guess i could split duplicated email adresses into several different calls. But I would really like to do one call, and send one array of recipients. Is it possible?
At this time, Mandrill uses email addresses as a unique identifier for merge vars in API calls, so it's only possible to provide one set of merge values for an email address, even if you've specified that address multiple times in the messages.to parameter. If you have multiple unique emails to send to the same recipient, that should be handled in separate API calls at this time.
I found an easier workaround than multiple API calls, and confirmed it works. Append a unique identifier to each email address using the "+" symbol. Then multiple emails to the same person will technically be to different email addresses, so Mandrill's merge fields will work correctly. e.g.
example+event1#example.com
example+event2#example.com
example+event3#example.com
All three of these will be delivered with the correct merging to example#example.com, and the recipient can even filter by the exact addresses if they wish when searching for the messages later.
(I am having the same issue now in 2019, so assume the original problem hasn't been fixed on Mandrill.)
Edit: The above method will not work with #yahoo.com recipients, as they don't support sub-addressing. The emails will bounce as if the address doesn't exist. (I consider that a problem with Yahoo, not the answer, since it's standard. But anyway, if you are emailing a group with a lot of yahoos... erm, yahoo.com emails I mean, then this method won't help.)

How would I model an email marketing graph in neo4j

I am really drawn (and new) to neo4j as a way to model my data for easier analysis. Part of my job requires that I analyze our email marketing efforts.
As a simple data model, I think of my graph as having 3 nodes:
Lead - the customer in the database
Email - the email sent to the customer(s)
URL - a link contained in an email
With the relationships being:
(Lead) -[:SENT]-> (Email)
(Lead) -[:OPEN]-> (Email)
(Lead) -[:CLICKED_THRU]-> (Email)
(EMAIL) -[:CONTAINS]-> (URL)
Now to my question. Using the data model I constructed above, how can I isolate the URLs that a Lead has clicked on. If I add another relationship (Lead) -[:CLICKED_ON]-> (URL), I do not know which email the URL was contained in (we send the same URL in multiple emails).
Right now, I have a traditional RDBMS implementation, where I know which lead clicked on which URLs from each email.
I want to try to learn neo4j using this business problem, but I am struggling as to how to relate the URL that was clicked on to the specific email.
Thanks in advance for any help. If this is not the proper forum, please let me know where I can direct my question.
The trouble with the model as you have it, is that in order for it to work you must assume that each email has one and only one link. That may not generally be true.
Now, if it is true that every email has only one link, then you could do what you wanted to this way:
MATCH (l:Lead)-[:CLICKED_THRU]->(e:Email)->[:CONTAINS]->(url:URL)
return l, url
This would tell you who clicked on which URL. But notice that if there's more than one URL per email, this would make it look like every user who ever clicked on an email link clicked on every link in that email.
A better way to model your data would be like this:
(Lead)-[:CLICKED_THRU]->(URL)
(EMAIL)-[:CONTAINS]->(URL)
(Lead)-[:OPEN]->(Email)
This would let you ask which URLs were clicked (just by following CLICKED_THRU but it would also tell you which emails were opened. Also, if URLs are unique to emails, by following the connection :CONTAINS you could know which email was opened by which link was clicked.
Finally, for general modeling concerns in neo4j, make sure to check out this presentation which goes into depth on how to think about modeling, and how it's different than relational.
I assume that at the point the URL is accessed you know which email it was from, that an E-Mail contains multiple URLs and that the same URLs may be present in multiple emails. You may want to model a hyper edge (something that links together more than two nodes) as a node:
(Lead)-[:CLICKED_URL_FROM]->(EmailLinkNode)
(EmailLinkNode)-[:FROM_EMAIL]->(email)
(EmailLinkNode)-[:CLICKED_URL]->(url)
I think that this is the only way to relate three Nodes in a single 'relationship', but I am quite new to this myself.
Something similar is described on the NeoTechnology page here.
I guess considering your data you could consider also think of creating a new Node to represent the concept of an EmailUrl which is a dummy node used to uniquely identify a url when related to a specific email.
(email)-[:CONTAINS]->(EmailUrl)-[:FOR_URL]->(url)
This leads to a simple relationship between the lead and the now unique node (lead)-[:CLICKED_THRU]->(EmailUrl) and therefore simple queries to find out not only which urls were clicked, but which emails proved the most enticing to your leads.

Email threading

I'm working at a helpdesk application where i have a standalone script that queries a mail server and parses the mail it finds there.
I'm facing the following issue: How do i figure it out in a reliable way what mail is in reply to what mail?
I could add something in the subject like "[ticket:21312]" and look for that but what if the user changes the subject? Is there another way? Can i do it by setting a custom mail header and look for that or the header will not be preserved between mail servers on reply back from user?
What about when i send a message from my application to a non existing user or a user that has quota full and his server replies back with the usual standard message "the mail daemon at .... could not ...." then the subject will also be modified and i can't place the message correctly as a reply to an existing mail.
How does gmail do it? There the messages are sorted perfectly in almost all of the cases.
in helpdesk email piping there are 3 basic methods:
a) include the id in the subject somewhere (works fine in practice)
b) have the id in the body somewhere
c) use an auto-generated email alias with the id, like "case-76236781980893#helpdesk.mycompany.com". that can easily be handled by something like procmail or a script to pick out the id.
gmail might use a combination of the subject, In-Reply-To header (may not be defined) (References and Original-Message-ID headers possibly as well), and various heuristics, which work very well, but of course not necessarily bulletproof, and slightly more involved to implement. something like nestscape's original threading algorithm perhaps. though some have reported that gmail doesn't use the In-Reply-To header and relies mostly on the subject (as in this post).
As you say custom headers might get lost and the subject might change. Use both. If one exists then you can identify the thread. I don't know of any better way to solve this.
If your message was sent with a Message-ID-Header any standards-conform mailer should add a In-Reply-To-Header referencing your Id. Additionally Referencesshould contain a list of all previous mails in this thread.
This works with most mail clients, to be safe for the bad clients you have to use the subject, the easy way is by adding the "[issue:123]" thing, a secondary fallback is to recognize the subject (after cutting of the "Re:" part in all the variations) for this it could help that you know most of your legitimate senders ...

Can an email be printed as soon as it enters the Inbox?

We are working on an online food ordering application. When the user orders something from any restaurant, an email is sent to the restaurant's email address mentioning the order details. However, our client wants that an order print out should be generated automatically as soon as a new order is received.
Is it feasible using ROR? If not, any alternate solution to the problem?
When my group wrote something like this we went a little lower tech, and had the system generate a fax and send it to a fax machine at the restaurant. Of course, that's mainly because this was a system working across many restaurants, with disparate IT infrastructures, and the one thing they had in common was each had a fax machine.
I would figure this could be done in 1 of two ways:
1- Outlook event-- Outlook has the ability to set up 'rules', one of which I think allows printing.
2- Create a script that runs every few minutes, checks the email (either through IMAP, or POP, depending on the account), and prints all of them out.
See this: http://ruby.about.com/od/tasks/a/pop3.htm for info on how to check POP3 mail with ruby on rails.
For printing, the links mentioned here seem useful: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/504a616bf3e28057/ff6cb91462dfe961?pli=1
Ensure that you have 'from' or 'subject' filters setup, otherwise there will be a lot of spam printing.
You can use software to print your order automatically when email is received, it supports also print attachment like pdf, word, etc...
It is used by a lot of restaurant to print online order:
http://www.automatic-email-manager.com/

Resources