Mailgun 如何使 Cc 和 Bcc 可选 php
Mailgun how to make Cc and Bcc optional php
我使用 mailgun 有一段时间了,我一直想知道如何使 cc/bcc 可选(所以如果用户想自己抄送,它会填充,否则不会填充).
$result = $mgClient->sendMessage($domain, array(
'from' => 'postmaster@example.com',
'to' =>'to@example.com',
'cc' => 'MAKE THIS OPTIONAL',
'h:Reply-To' => 'reply@example.com',
'subject' => 'Subject,
'html' => '<!doctype html>....'
接下来是更简单的方法。
如果您填写了'cc'
或'bcc'
,例如在$_POST
或$_GET
中:
$default_array = [
'from' => 'postmaster@example.com',
'to' =>'to@example.com',
'h:Reply-To' => 'reply@example.com',
'subject' => 'Subject,
'html' => '<!doctype html>....
];
if (!empty($_POST['cc']) && isset($_POST['cc'])) $default_array['cc'] = $_POST['cc'];
// the same with 'bcc' and others
$result = $mgClient->sendMessage($domain, $default_array);
我使用 mailgun 有一段时间了,我一直想知道如何使 cc/bcc 可选(所以如果用户想自己抄送,它会填充,否则不会填充).
$result = $mgClient->sendMessage($domain, array(
'from' => 'postmaster@example.com',
'to' =>'to@example.com',
'cc' => 'MAKE THIS OPTIONAL',
'h:Reply-To' => 'reply@example.com',
'subject' => 'Subject,
'html' => '<!doctype html>....'
接下来是更简单的方法。
如果您填写了'cc'
或'bcc'
,例如在$_POST
或$_GET
中:
$default_array = [
'from' => 'postmaster@example.com',
'to' =>'to@example.com',
'h:Reply-To' => 'reply@example.com',
'subject' => 'Subject,
'html' => '<!doctype html>....
];
if (!empty($_POST['cc']) && isset($_POST['cc'])) $default_array['cc'] = $_POST['cc'];
// the same with 'bcc' and others
$result = $mgClient->sendMessage($domain, $default_array);