我对 PHP 非常陌生,正在联系页面上使用基本模板“发送邮件”表单。
当单击“提交”按钮时,要求我将电子邮件发送到多个电子邮件地址。我已经四处搜寻,但还没有找到我需要的东西。我需要在下面的表单中添加什么代码才能将其发送到多个电子邮件地址?
<?php
$mail_to = '[email protected] /cdn-cgi/l/email-protection'; // specify your email here
// Assigning data from the $_POST array to variables
$name = $_POST['sender_name'];
$mail_from = $_POST['sender_email'];
$phone = $_POST['sender_phone'];
$web = $_POST['sender_web'];
$company = $_POST['sender_company'];
$addy = $_POST['sender_addy'];
$message = $_POST['sender_message'];
// Construct email subject
$subject = 'Web Prayer Request from ' . $name;
// Construct email body
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Phone: ' . $phone . "\r\n";
$body_message .= 'Prayer Request: ' . $message;
// Construct email headers
$headers = 'From: ' . $name . "\r\n";
$headers .= 'Reply-To: ' . $mail_from . "\r\n";
$mail_sent = mail($mail_to, $subject, $body_message, $headers);
if ($mail_sent == true){ ?>
<script language="javascript" type="text/javascript">
alert('Your prayer request has been submitted - thank you.');
window.location = 'prayer-request.php';
</script>
<?php } else { ?>
<script language="javascript" type="text/javascript">
alert('Message not sent. Please, notify the site administrator [email protected] /cdn-cgi/l/email-protection');
window.location = 'prayer-request.php';
</script>
<?php
}
?>
非常感谢您的帮助。
您破坏了一组收件人:
$recipients = array('[email protected] /cdn-cgi/l/email-protection', '[email protected] /cdn-cgi/l/email-protection');
mail(implode(',', $recipients), $submit, $message, $headers);
请参阅 PHP:邮件函数参考 -http://php.net/manual/en/function.mail.php http://php.net/manual/en/function.mail.php
收件人,或邮件的接收者。
该字符串的格式必须符合 » RFC 2822。一些示例是:
[email protected] /cdn-cgi/l/email-protection
-
[email protected] /cdn-cgi/l/email-protection
, [email protected] /cdn-cgi/l/email-protection
- User
<[email protected] /cdn-cgi/l/email-protection>
- User
<[email protected] /cdn-cgi/l/email-protection>
, 另一个用户 [email protected] /cdn-cgi/l/email-protection>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)