Я хочу отправить электронные письма пользователям после заполнения и отправки формы, я использовал метод 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
Добро пожаловать ! Не забывайте отмечать вопрос как решаемый! –