I'm using Mandrill's Ruby API Gem and have the follow simple template for testing:
<html>
<body>
<h1 mc:edit="header">testastic</h1>
<hr/>
<br/><br/>
<div mc:edit="main_section"></div>
<hr/>
<div mc:edit="footer"></div>
</body>
</html>
Following the example on Heroku's guide I have the follow Ruby code:
require 'mandrill'
m = Mandrill::API.new
rendered = m.templates.render 'test-template', [{:header => 'some header text', :main_section => 'The main content block', :footer => '<h3>asdf</h3>'}]
mail(:to => "Jayson Lane <[email protected]>", :subject => "Test Email") do |format|
format.html { rendered['html'] }
#format.text { render "test" }
end
This works great and the email sends my template just fine, however, it doesn't replace the template mc:edit variables. Am I missing something?
Use the drag and drop template editor to make the desired template, then copy the code and paste it into the Mandrill template editor. Or connect your Mandrill and Mailchimp accounts and let Mandrill copy your templates over for you.
Mandrill is a transactional email API for MailChimp users. It's reliable, powerful, and ideal for sending data driven emails, including targeted e-commerce and personalized one-to-one messages.
Click on “Launch Mandrill”. Click on “Setup your sending domain” button and add your domain name. It will ask you the email associated with the domain name in order to verify it. It will send you an email, click on the link to verify your account.
Mailchimp's campaign templates use responsive design to adjust the layout of your campaign to look great on any device. But, not every device handles responsive code the same way, which can make your campaign look a little different on mobile than in a web browser.
Get official API clients (and documentation) and test each call right in your browser using Mandrill's executable API docs. Start sending emails in a matter of minutes with Mandrill's quick-start SMTP Integration. Explore official and 3rd party wrappers and integrations to streamline your connection to Mandrill.
Feb 21 '15 at 17:56 You might want to consider an email templating service, instead of interfacing with Mandrill directly. Checkout sendwithus.com or customer.io. Both make it much easier to manage variables, and work well with C#. – bvanvugt
Mandrill is a scalable and affordable email infrastructure service. Whether you're just getting started, have some questions, or are looking for a quick reference, we've got you covered. What you need to know before you begin. From the basics to FAQs, learn how Mandrill can help further your email experience.
You need to construct a hash for each element you're trying to replace. For instance, I have this inside of a template:
<h3 mc:edit="plan_info_name"> </h3>
<span mc:edit="plan_info_description"> </span>
<span mc:edit="plan_info_benefits"> </span>
And this on the mailer:
mandrill.messages.send_template(template,[
{
:name => 'plan_info_name',
:content => extra[:membership_info].name
},
{
:name => 'plan_info_description',
:content => extra[:membership_info].long_description
},
{
:name => 'plan_info_benefits',
:content => benefits_list
}
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With