Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当变量用作PHP值时,Mailgun不发送电子邮件_Php_Email_Mailgun - Fatal编程技术网

当变量用作PHP值时,Mailgun不发送电子邮件

当变量用作PHP值时,Mailgun不发送电子邮件,php,email,mailgun,Php,Email,Mailgun,无论何时硬编码“to”值,都会发送电子邮件。但是,当字符串值替换为字符串变量时,不会发送电子邮件 $result = $mgClient->sendMessage($domain, array( 'from' => 'Eemayl Ok <mailgun@domain.net>', 'to' => $customerEmail, 'to' => Tools::safeOutput($customerEmail)

无论何时硬编码“to”值,都会发送电子邮件。但是,当字符串值替换为字符串变量时,不会发送电子邮件

$result = $mgClient->sendMessage($domain, array(
    'from'    => 'Eemayl Ok <mailgun@domain.net>',
    'to'      => $customerEmail,
    'to'      => Tools::safeOutput($customerEmail),
    'to'      => (string)$customerEmail,
    'to'      => $customer->email,
    'to'      => Tools::safeOutput($customer->email),
    'to'      => 'hardcoded_email@gmail.com',
    'subject' => 'We Hope You get this Email!',
    'text'    => '',
    'html'      => '<html>Contact Us Ok??</a></html>'       
));
$result=$mgClient->sendMessage($domain,array)(
'来自'=>'Eemayl Ok',
'至'=>$customerEmail,
'to'=>Tools::safeOutput($customerEmail),
'至'=>(字符串)$customerEmail,
'发送至'=>$customer->电子邮件,
'至'=>Tools::safeOutput($customer->email),
'到'=>'硬编码_email@gmail.com',
“主题”=>“我们希望您收到此电子邮件!”,
'文本'=>'',
'html'=>'联系我们好吗
));

几个“to”是我尝试表达变量值的变体。

数组不接受重复键。它仅在键重复时选择最后一个值。根据,您应该使用逗号分隔多个收件人

$recipients = array('client1@gmail.com', 'client2@gmail.com');
$result = $mgClient->sendMessage($domain, array(
    'from'    => 'Eemayl Ok <mailgun@domain.net>',
    'to'      => implode(',', $recipients),
    'subject' => 'We Hope You get this Email!',
    'text'    => '',
    'html'      => '<html>Contact Us Ok??</a></html>'       
));
$recipients=数组('client1@gmail.com', 'client2@gmail.com');
$result=$mgClient->sendMessage($domain,array)(
'来自'=>'Eemayl Ok',
'到'=>内爆(',',$recipients),
“主题”=>“我们希望您收到此电子邮件!”,
'文本'=>'',
'html'=>'联系我们好吗
));

感谢您的回复,我在几个小时前就知道了这一点,现在正忙于完成项目。(仍在忙着)然而,我只是用不同的电子邮件打了几个电话