If you already have a MailChimp account, linking it to your Mandrill account allows you to take advantage of bundled pricing. For each MailChimp account, you can link to one Mandrill account. A Mandrill account can be linked to multiple MailChimp accounts.This tutorial will help you to setup mandrill-mailchimp intigration.
you can send emails through the Mandrill API or SMTP integration. With the Mandrill API, you can send emails, get information about your account, and view or parse reporting data in your own app or system. Point your developer to these resources to get started.
-
[Create Mandrill accout] mandrillac
-
Add a New Sending Domain
-Go to Settings -Choose Sending Domains. -Type a new domain at the top and click Add.
Now that you've added a new sending domain, add the appropriate records to your domain's DNS settings.
- [Create Mailchimp accout] mailchimpac
-In your MailChimp account, click your profile name to expand the Account Panel, and click Account.
-Click the Integrations option.
-Click the Mandrill option.
-Click Authorize Connection.
-You'll be redirected to the Mandrill login page to enter your Mandrill username and password.
-After providing your Mandrill username and password, you'll see a message asking if you'd like to grant MailChimp access to your Mandrill account.
-Grant MailChimp access to your Mandrill account
-Click Allow to connect your accounts or Deny to cancel the connection attempt.
-Navigate to the Templates page in your MailChimp account.
-Locate the template you'd like to copy by browsing the template list or using the search option.
-Click the template's drop-down menu and choose Send To Mandrill.
-You'll see a success message once your template has been saved to your Mandrill account.
But templates in Mandrill work differently than in MailChimp, so you may need to tweak your templates for Mandrill.
- Now signin in mandrill
-Navigate to the outboud in your Mandrill account.
-Select templete page.
-Here you can find listing of mailchimp template.
Now you can use those template in your mandrill account with help of following API.
All of the mandrill api can be viewed/obtained through Bitbucket or the language-specific repositories listed below.
{
"key": "your_api_key",
"template_name": "example template_name",
"template_content": [
{
"name": "example name",
"content": "example content"
}
],
"message": {
"html": "<p>Example HTML content</p>",
"text": "Example text content",
"subject": "example subject",
"from_email": "[email protected]",
"from_name": "Example Name",
"to": [
{
"email": "[email protected]",
"name": "Recipient Name",
"type": "to"
}
],
"headers": {
"Reply-To": "[email protected]"
},
"important": false,
"track_opens": null,
"track_clicks": null,
"auto_text": null,
"auto_html": null,
"inline_css": null,
"url_strip_qs": null,
"preserve_recipients": null,
"view_content_link": null,
"bcc_address": "[email protected]",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"merge_language": "mailchimp"
},
"async": false,
"ip_pool": "Main Pool"
}
<?php
try {
$mandrill = new Mandrill('YOUR_API_KEY');
$template_name = 'example template_name';
$template_content = array(
array(
'name' => 'example name',
'content' => 'example content'
)
);
$message = array(
'html' => '<p>Example HTML content</p>',
'text' => 'Example text content',
'subject' => 'example subject',
'from_email' => '[email protected]',
'from_name' => 'Example Name',
'to' => array(
array(
'email' => '[email protected]',
'name' => 'Recipient Name',
'type' => 'to'
)
),
'headers' => array('Reply-To' => '[email protected]'),
'important' => false,
'track_opens' => null,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => null,
'view_content_link' => null,
'bcc_address' => '[email protected]',
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true,
'merge_language' => 'mailchimp'
);
$async = false;
$ip_pool = 'Main Pool';
$send_at = 'example send_at';
$result = $mandrill->messages->sendTemplate($template_name, $template_content, $message, $async, $ip_pool);
print_r($result);
} catch(Mandrill_Error $e) {
// Mandrill errors are thrown as exceptions
echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
// A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
throw $e;
}
?>
mandrill_client = new mandrill.Mandrill('YOUR_API_KEY');
var message = {
"html": "<p>Example HTML content</p>",
"text": "Example text content",
"subject": "example subject",
"from_email": "[email protected]",
"from_name": "Example Name",
"to": [{
"email": "[email protected]",
"name": "Recipient Name",
"type": "to"
}],
"headers": {
"Reply-To": "[email protected]"
},
"important": false,
"track_opens": null,
"track_clicks": null,
"auto_text": null,
"auto_html": null,
"inline_css": null,
"url_strip_qs": null,
"preserve_recipients": null,
"view_content_link": null,
"bcc_address": "[email protected]",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"merge_language": "mailchimp"
};
var async = false;
var ip_pool = "Main Pool";
mandrill_client.messages.send({"message": message, "async": async, "ip_pool": ip_pool}, function(result) {
console.log(result);
/*
[{
"email": "[email protected]",
"status": "sent",
"reject_reason": "hard-bounce",
"_id": "abc123abc123abc123abc123abc123"
}]
*/
}, function(e) {
// Mandrill returns the error as an object with name and message keys
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
// A mandrill error occurred: Unknown_Subaccount - No subaccount exists with the id 'customer-123'
});
begin
mandrill = Mandrill::API.new 'YOUR_API_KEY'
template_name = "example template_name"
template_content = [{"content"=>"example content", "name"=>"example name"}]
message = {"google_analytics_campaign"=>"[email protected]",
"merge_language"=>"mailchimp",
"inline_css"=>nil,
"subaccount"=>"customer-123",
"merge"=>true,
"return_path_domain"=>nil,
"url_strip_qs"=>nil,
"track_clicks"=>nil,
"headers"=>{"Reply-To"=>"[email protected]"},
"view_content_link"=>nil,
"to"=>
[{"type"=>"to",
"email"=>"[email protected]",
"name"=>"Recipient Name"}],
"html"=>"<p>Example HTML content</p>",
"google_analytics_domains"=>["example.com"],
"from_name"=>"Example Name",
"text"=>"Example text content"
"tracking_domain"=>nil,
"subject"=>"example subject",
"signing_domain"=>nil,
"auto_html"=>nil,
"track_opens"=>nil,
"from_email"=>"[email protected]",
"auto_text"=>nil,
"important"=>false}
async = false
ip_pool = "Main Pool"
result = mandrill.messages.send_template template_name, template_content, message, async, ip_pool
# [{"status"=>"sent",
# "reject_reason"=>"hard-bounce",
# "email"=>"[email protected]",
# "_id"=>"abc123abc123abc123abc123abc123"}]
rescue Mandrill::Error => e
# Mandrill errors are thrown as exceptions
puts "A mandrill error occurred: #{e.class} - #{e.message}"
# A mandrill error occurred: Mandrill::UnknownSubaccountError - No subaccount exists with the id 'customer-123'
raise
end
- Setup DNS verification of mandrill.
- Generate api key from mandrill account.
- Remove unwanted parameters from api call.