php邮件功能发送多封电子邮件
我正在尝试用php mail实现简单的电子邮件功能。代码如下,
$headers = 'From: "From Display Name" <[email protected]>' . PHP_EOL .
'Cc: "CC Display Name" <[email protected]>' . PHP_EOL .
'X-Mailer: PHP-' . phpversion() . PHP_EOL;
if(mail('[email protected]', 'test', 'test message', $headers, '[email protected]')) echo "sent";
else "not sent";
但问题是这段代码发送同一封电子邮件 6 次,我不明白为什么......有什么想法吗? “虽然已发送,但只回显一次!!!”
完整代码:
if($_POST['submitted']=="1"){
$error = "";
if($error==""){
$headers = 'From: "From Display Name" <[email protected]>' . PHP_EOL .
'Cc: "CC Display Name" <[email protected]>' . PHP_EOL .
'X-Mailer: PHP-' . phpversion() . PHP_EOL;
if(mail('[email protected]', 'test', 'test message', $headers, '[email protected]')) echo "sent";
else "not sent";
}
}
I am trying to implement the simple email function with php mail. Code is as follows
$headers = 'From: "From Display Name" <[email protected]>' . PHP_EOL .
'Cc: "CC Display Name" <[email protected]>' . PHP_EOL .
'X-Mailer: PHP-' . phpversion() . PHP_EOL;
if(mail('[email protected]', 'test', 'test message', $headers, '[email protected]')) echo "sent";
else "not sent";
But problem is this code is sending the same email 6 times, and i can not figureout why... any ideas?
The "Sent is echoed only one time though!!!"
Complete CODE:
if($_POST['submitted']=="1"){
$error = "";
if($error==""){
$headers = 'From: "From Display Name" <[email protected]>' . PHP_EOL .
'Cc: "CC Display Name" <[email protected]>' . PHP_EOL .
'X-Mailer: PHP-' . phpversion() . PHP_EOL;
if(mail('[email protected]', 'test', 'test message', $headers, '[email protected]')) echo "sent";
else "not sent";
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,原因如下:为了验证和“!!|-: 安全:-|!!”检查,该模板在浏览器中显示结果之前被调用了 6 次!!!!!!!!!!
ok, here is the reason: For validation and "!!|-: SECURITY :-|!!" checks, that template is getting called 6 times before Showing the results in browser!!!!!!!!!!