我想在用戶填寫並提交表單後向用戶發送電子郵件,我使用POST方法捕獲數據,現在我想用捕獲的變量替換靜態文本從形式。我從表單中提供了一些可變數據樣本。如何用Mandrill腳本中的動態變量替換靜態文本
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
$uri = 'https://mandrillapp.com/api/1.0/messages/send.json';
$postString = '{
"key": "xxxxxxxxxxxxx",
"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;
好,謝謝會給它一個嘗試,希望它能 – eugbana
感謝拉斐爾你是非常有益的,它的工作只是我想它的方式 – eugbana
不客氣!不要忘記標記問題已解決! –