Mandrill 接受其所有 API 方法的 HTTP 请求,并将您的输入作为 JSON 字符串。下面是发送电子邮件的基本示例。它用于执行 HTTP 请求:POSTcURL
$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": "someone@example.com",
    "from_name": "John",
    "to": [
        {
            "email": "blah@example.com",
            "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;