gpt4 book ai didi

PHP Send-Mail 表单到多个电子邮件地址

转载 作者:可可西里 更新时间:2023-10-31 23:54:54 24 4
gpt4 key购买 nike

我是 PHP 的新手,正在使用联系页面上的基本模板“发送邮件”表单。单击“提交”按钮时,要求我将电子邮件发送到多个电子邮件地址。我四处搜寻并没有完全找到我需要的东西。我需要在下面的表格中添加什么代码才能将其发送到多个电子邮件地址?

<?php     

$mail_to = 'daniel30293@gmail.com'; // 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 admin@bondofperfection.com');

window.location = 'prayer-request.php';
</script>

<?php

}

?>

非常感谢您的帮助。

最佳答案

你内爆了一系列的收件人:

$recipients = array('jack@gmail.com', 'jill@gmail.com');

mail(implode(',', $recipients), $submit, $message, $headers);

请参阅 PHP:邮件函数引用 - http://php.net/manual/en/function.mail.php

收件人,或邮件的收件人。

此字符串的格式必须符合 » RFC 2822。一些例子是:

  • user@example.com
  • user@example.com , anotheruser@example.com
  • 用户 <user@example.com>
  • 用户 <user@example.com> , 另一个用户 < anotheruser@example.com >

关于PHP Send-Mail 表单到多个电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14541839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com