使用PHP的mail()
功能时,我会在"到"参数设置为:
"test@example2.com,test@example1.com"
但当我把它们换成圆形时:
"test@example1.com,test@example2.com"
电子邮件已发送至test@example2.com
,但未发送至test@example1.com
。如果指定为CC或BCC标题,它也不会收到电子邮件。
有人可以建议为什么会这样吗?几个星期前它一直工作正常。据我所知,我的服务器上没有任何变化,虽然它是共享主机,所以它可能有。
注意事项:mail()
函数始终返回true
,无论顺序如何。 example1.com
也是发送服务器。
我的代码如下:
$from = 'sales@example1.com';
$headers = '';
$headers .= 'From: My Site <' . $from . ">\r\n" .
'Reply-To: ' . $_POST["Email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$body = 'Message goes here';
$to = 'test@example1.com,test@example2.com'; // will not send to test@example2.com, though will if the addresses are swapped
if ( mail( $to, 'Subject goes here', $body, $headers, '-f ' . $from ) ) {
$url = "/contact/?message=sent";
} else {
$url = "/contact/?message=failed";
}
header("Location: $url");
答案 0 :(得分:0)
查看PHP手册,我注意到该示例在逗号后面有一个空格。 试试
$to = 'test@example1.com, test@example2.com';
您还可以使用标题部分添加CC
$headers .= 'Cc: 2ndaddress@example.com' . "\r\n";