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

问题描述 投票:0回答:1

只要“to”值被硬编码,就会发送电子邮件。但是,当字符串值替换为字符串变量时,电子邮件不会被发送。

$result = $mgClient->sendMessage($domain, array(
    'from'    => 'Eemayl Ok <[email protected]>',
    'to'      => $customerEmail,
    'to'      => Tools::safeOutput($customerEmail),
    'to'      => (string)$customerEmail,
    'to'      => $customer->email,
    'to'      => Tools::safeOutput($customer->email),
    'to'      => '[email protected]',
    'subject' => 'We Hope You get this Email!',
    'text'    => '',
    'html'      => '<html>Contact Us Ok??</a></html>'       
));

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

php email mailgun
1个回答
1
投票

Array不接受重复键。如果密钥重复,它只选择最后一个值。根据mailgun API,您应该使用逗号分隔多个收件人。

$recipients = array('[email protected]', '[email protected]');
$result = $mgClient->sendMessage($domain, array(
    'from'    => 'Eemayl Ok <[email protected]>',
    'to'      => implode(',', $recipients),
    'subject' => 'We Hope You get this Email!',
    'text'    => '',
    'html'      => '<html>Contact Us Ok??</a></html>'       
));
© www.soinside.com 2019 - 2024. All rights reserved.