Send-Template delivers empty content

3,217 views
Skip to first unread message

Christopher Troup

unread,
Jul 9, 2012, 9:18:09 PM7/9/12
to mandrill-a...@googlegroups.com
Hello!

I've stripped down a template as a test case -- just one mc:edit field. The API logs show a request like:

{"key": "*****************", "template_name": "gtrax", "template_content": [{"name": "content", "content": "<p>Hello, world!<\/p>"}], "message": {"text": "plain text version", "subject": "Welcome Test", "from_email": "fa...@emailaddress.com", "from_name": "gTrax Support", "to": [{"email": "anoth...@emailaddress.com", "name": "Chris Troup"}], "track_opens": true, "track_clicks": true, "auto_text": false, "url_strip_qs": false, "tags": ["hello", "world"], "google_analytics_domains": ["app.gtraxapp.com"], "google_analytics_campaign": ["welcome_to_gtrax"], "headers": {}}}

However, the email as delivered contains ONLY the plain text content (to GMail). If I omit the message:text field (or set it to null) the delivered body is completely empty. The template "gtrax" does exist.

Server hiccup or PEBKAC? :)

Thanks!
Christopher Troup

Christopher Troup

unread,
Jul 9, 2012, 9:21:04 PM7/9/12
to mandrill-a...@googlegroups.com
Should also note that delivered email headers show Content-Type: text/plain; charset=utf-8 as the content type, not HTML or MIME encapsulated, as expected.

Kaitlin

unread,
Jul 9, 2012, 10:23:47 PM7/9/12
to mandrill-a...@googlegroups.com
Hey Christopher,

Tested out the same json request in a test account here (with actual email addresses of course) and a basic template as well - everything seems to be delivered to Gmail as expected. Any chance you've got a threaded conversation and Gmail's killing part of it with the smart quoting or that images aren't being downloaded?  If you're still having issues, shoot us an email from help.mandrill.com and we can take a closer look at your particular template and account.

Christopher Troup

unread,
Jul 9, 2012, 10:31:29 PM7/9/12
to mandrill-a...@googlegroups.com
Thanks, replied via that form.

SheepDogInc.ca Christopher Troup
Sr. Developer
Office 902.442.8227  |  Fax 902.450.5401
211 Horseshoe Lake Drive  |  Halifax  |  NS  |  B3S 0B9
Google Apps Premier Enterprise Reseller



--
You received this message because you are subscribed to the Google Groups "Mandrill API Discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mandrill-api-discuss/-/zNKPCy1VdQoJ.

To post to this group, send email to mandrill-a...@googlegroups.com.
To unsubscribe from this group, send email to mandrill-api-dis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mandrill-api-discuss?hl=en.

Jake

unread,
Jul 20, 2012, 7:10:25 PM7/20/12
to mandrill-a...@googlegroups.com
I'm having the same problem. I have a template called "colorfield" and when I try sending, it will only send plain text or a completely empty message if I take the text field out.

What am I doing wrong? I'm completely new to this, just trying to get a hello world to work :)

thanks!


<?php

$args = array(
    "key" => "***************", 
    "template_name" => "colorfield", 
    "template_content" => array(
        "name" => "content",
"content" => "Hello, world!"
),
    "message" => array(
        "subject" => "Your recent application",
        "from_email" => "in...@schoolemail.com",
        "from_name" => "Alma Heights Christian Schools",
        "to" => array(
        array(
        "email" => "ja...@gmail.com",
        "name" => "Jake"
        )
        ),
        "track_opens" => true,
        "track_clicks" => true,
        "auto_text" => true,
        "url_strip_qs" => true, 
        "preserve_recipients" => true
    )   
);


curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args));
$response = curl_exec($curl);
curl_close($curl);


var_export($response);


?>

Kaitlin

unread,
Jul 20, 2012, 9:39:30 PM7/20/12
to mandrill-a...@googlegroups.com
Jake - looks like you're hitting the messages/send endpoint instead of messages/send-template - this means no HTML is being provided because the template isn't actually being pulled in for the HTML content.  We're working to tighten up some of the API validation but for now if you provide template parameters for messages/send, the template won't actually be used.

Jake

unread,
Jul 21, 2012, 10:31:09 AM7/21/12
to mandrill-a...@googlegroups.com
Is there a simple template example that could get me on my way? Like I said I'm totally new to Mandrill so I'm not even sure how I send it without using template variables in the messages/send.

Kaitlin

unread,
Jul 22, 2012, 2:08:12 AM7/22/12
to mandrill-a...@googlegroups.com
What kind of example are you thinking? The HTML for a template, or an example of making an API call and using a template?

If you are hitting messages/send.json, then you'll provide the full content for your message. If you want to send HTML content, provide the full HTML as part of the message. If you're only sending text, provide the text content.  If you're providing HTML, you can also provide text, or you can let Mandrill automatically convert your HTML to text.  The send and send-template calls are very similar, but you can't create your HTML content from a stored template if you're calling messages/send.json since it doesn't use template parameters. You have to provide the full HTML content in the API call.

Here's the API info for messages/send.json: https://mandrillapp.com/api/docs/messages.html#method=send

and for messages/send-template.json:https://mandrillapp.com/api/docs/messages.html#method=send-template

Jake

unread,
Jul 23, 2012, 2:58:43 PM7/23/12
to mandrill-a...@googlegroups.com
Ok, nevermind, I wasn't sending it to the right JSON file. Oops!

But now I'm getting a validation message: '{"status":"error","code":-2,"name":"ValidationError","message":"Validation error: {\\"template_content\\":[\\"Please enter an array\\"],\\"message\\":{\\"global_merge_vars\\":[\\"Please enter an array\\"]}}"}'

But I am sending an array (doing this through PHP):

"template_content" => array(
                "name" => "content",
"content" => "Hello, world!"
),

...


"global_merge_vars" => array(
"name" => "content",
"content" => "Hello, world!"
),
"merge_vars" => array(
"vars" => array(
"name" => "example name",
"content" => "example content"
),
"tags" => array(
"name" => "example name",
"content" => "example content"
)
),


I'm not quite sure how to handle the tags and the template content. I just want to do a simple hello world to get me going. Any way I can simplify this?

Thanks!

Kaitlin

unread,
Jul 25, 2012, 4:47:10 PM7/25/12
to mandrill-a...@googlegroups.com
Hey Jake,

Sorry for the delay in responding. It looks like you're trying to provide the same details in three different ways (editable area in a template, global merge var and merge var), and in this case, you really only need to use one of these if you're sending to a single recipient.

For merge_vars, you'll need to provide a recipient for each set, so that Mandrill knows which recipient should be getting which merge information.

Your final JSON when hitting messages/send-template.json should look something like what's shown below.  I've added some notes to the right of things to provide context/explanation.


{
    "key": "example key",
    "template_name": "MyTemplate",  //This is the name of the stored template in your account
    "template_content": [
        {
            "name": "main",  //This is the name of the mc:edit region in the stored template
            "content": "Hi there *|FNAME|*! Glad you joined us this week." //This is what you want to put in the mc:edit region replacing what's in that region of the template
        }
    ],
    "message": {
        "text": "example text",
        "subject": "example subject",
        "from_email": "message.f...@example.com",
        "from_name": "example from_name",
        "to": [
            {
                "email": "Ja...@domain.com",
                "name": "Jake"
            }
        ],
        "global_merge_vars": [
            {
                "name": "FNAME",  // This is the merge tag that's included in your email content, such as *|FNAME|*
                "content": "Friend" // This is the default value to use if someone doesn't have a recipient-specific value for FNAME
            }
        ],
        "merge_vars": [
            {
                "rcpt": "Ja...@domain.com",
                "vars": [
                    {
                        "name": "FNAME",
                        "content": "Jake" //Recipient-specific value for the merge tag; here, FNAME
                    }
                ]
            }
        ],

mryangyu

unread,
Aug 26, 2012, 5:07:59 PM8/26/12
to mandrill-a...@googlegroups.com
Only FNAME is working.

Other merge field names are not being replaced.


{"auto_text":true,"global_merge_vars":[{"content":"New Follower","name":"SUBJECT"},{"content":"New Follower","name":"TITLE"},{"content":"View Follower","name":"ACTION"},{"content":"http:\/\/beta.lookflix.com\/#profiles\/4c95c2c7-0968-479e-ab2c-e412c5079652","name":"ACTIONURL"},{"content":"tester1 haha is now following your looks.","name":"MESSAGE"}],"key":"a3f8f002-a294-45ff-882e-ef7422b5347b","merge_vars":[{"rcpt":"___@gmail.com","vars":[{"content":"Yang Yu","name":"FNAME"}]}],"message":{"from_email":"___@lookflix.com","from_name":"LookFlix","subject":"New Follower","text":null,"to":[{"email":"____@gmail.com","name":"Yang Yu"}]},"preserve_recipients":false,"template_content":[],"template_name":"LookFlix Standard Mail","track_clicks":true,"track_opens":true,"url_strip_qs":false}
Reply all
Reply to author
Forward
Message has been deleted
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages