Mailgun如何使Cc和Bcc成为可选php

Mailgun如何使Cc和Bcc成为可选php,php,mailgun,Php,Mailgun,我使用mailgun已经有一段时间了,我一直想知道如何使cc/bcc成为可选的(因此,如果用户想要抄送自己,它将填充,如果不想,它将不会填充) $result=$mgClient->sendMessage($domain,array( '来自'=>'postmaster@example.com', '到'=>'to@example.com', “cc'=>“将此设置为可选”, 'h:回复'=>'reply@example.com', “主题”=>“主题, 'html'=>'…' 更简单的方

我使用mailgun已经有一段时间了,我一直想知道如何使cc/bcc成为可选的(因此,如果用户想要抄送自己,它将填充,如果不想,它将不会填充)

$result=$mgClient->sendMessage($domain,array(
'来自'=>'postmaster@example.com', 
'到'=>'to@example.com', 
“cc'=>“将此设置为可选”,
'h:回复'=>'reply@example.com', 
“主题”=>“主题,
'html'=>'…'

更简单的方法是下一步

如果您填写了
'cc'
'bcc'
,例如,在
$\u POST
$\u 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);
$default\u数组=[
'来自'=>'postmaster@example.com', 
'到'=>'to@example.com', 
'h:回复'=>'reply@example.com', 
“主题”=>“主题,
“html”=>“。。。。
];
如果(!empty($_POST['cc'])和&isset($_POST['cc'])默认数组['cc']=$_POST['cc'];
//“密件抄送”和其他人也是如此
$result=$mgClient->sendMessage($domain,$default\u数组);

更简单的方法是下一步

如果您填写了
'cc'
'bcc'
,例如,在
$\u POST
$\u 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);
$default\u数组=[
'来自'=>'postmaster@example.com', 
'到'=>'to@example.com', 
'h:回复'=>'reply@example.com', 
“主题”=>“主题,
“html”=>“。。。。
];
如果(!empty($_POST['cc'])和&isset($_POST['cc'])默认数组['cc']=$_POST['cc'];
//“密件抄送”和其他人也是如此
$result=$mgClient->sendMessage($domain,$default\u数组);

你刚刚说了答案。如果你喜欢索引,它是一个基本的if-else语句或三元运算符,但我不能为cc提交空值?你刚刚说了答案。如果你喜欢索引,它是一个基本的if-else语句或三元运算符,但我不能为cc提交空值?