मंड्रिल HTTP POST
उनके सभी API विधियों के लिए अनुरोध लेते हैं, और वे आपके इनपुट को JSON स्ट्रिंग के रूप में लेते हैं। ईमेल भेजने का मूल उदाहरण यहां दिया गया है। यह cURL
का उपयोग करता HTTP अनुरोध करने के लिए:
$uri = 'https://mandrillapp.com/api/1.0/messages/send.json';
$postString = '{
"key": "YOUR KEY HERE",
"message": {
"html": "this is the emails html content",
"text": "this is the emails text content",
"subject": "this is the subject",
"from_email": "[email protected]",
"from_name": "John",
"to": [
{
"email": "[email protected]",
"name": "Bob"
}
],
"headers": {
},
"track_opens": true,
"track_clicks": true,
"auto_text": true,
"url_strip_qs": true,
"preserve_recipients": true,
"merge": true,
"global_merge_vars": [
],
"merge_vars": [
],
"tags": [
],
"google_analytics_domains": [
],
"google_analytics_campaign": "...",
"metadata": [
],
"recipient_metadata": [
],
"attachments": [
]
},
"async": false
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
$result = curl_exec($ch);
echo $result;
भविष्य के उपयोगकर्ताओं के लिए एक नोट के रूप में, आपको आउटबाउंड -> टेम्पलेट मेनू के नीचे मिले मंडल में एक टेम्पलेट बनाना होगा निम्नानुसार न्यूनतम HTML:
टेम्पलेट स्लॉग स्टेशनरी से मेल खाना चाहिए। टेम्पलेट्स पर और जानकारी यहां मिल सकती है http://help.mandrill.com/entries/21694286-How-do-I-add- गतिशील- सामग्री- उपयोग करने योग्य-regions-in-my-template- – Treemonkey