gpt4 book ai didi

php - 向两个地址发送电子邮件?

转载 作者:行者123 更新时间:2023-12-01 06:58:23 24 4
gpt4 key购买 nike

是否可以使用以下代码将查询电子邮件发送到两个地址?如果是这样,我会怎么做?

<?php if(isset($_GET['emailme']) && $_GET['emailme'] == 'true') { 
// to and subject
$to = "info@domain.com";
$subject = "Product enquiry";

// get these from query string
$name_field = $_GET['name'];
$hospital_field = $_GET['hospital'];
$department_field = $_GET['department'];
$email_field = $_GET['email'];
$tel_field = $_GET['tel'];

// get wishlist
$query = "SELECT w.*, p.product_name, q.quantity_name, o.product_code, o.description
FROM wishlistbasket w, products p, product_quantities q, product_options o
WHERE sesid = '$sesid' AND w.pid = p.id AND w.qid = q.id AND w.oid = o.id ORDER BY w.pid, w.qid, w.oid";
$res = mysql_query($query);
$wish_list = '';
if($res){
while($row = mysql_fetch_assoc($res)) {
if ($row['qty'] == 1) {
$row['qty'] = "Quote";
} else if ($row['qty'] == 2) {
$row['qty'] = "Sample";
} else if ($row['qty'] == 3) {
$row['qty'] = "Quote and Sample";
}
$wish_list .= $row['product_code'] . ' - ' . $row['product_name'] . ', ' . $row['quantity_name'] . ', ' . $row['qty'] . '' . $row['product_options'] . "
\n";
}
}

// build mail body
$body = "Hello,\n\n
You have an enquiry from the website, please see the details below:\n\n
Name: $name_field\n
Hospital/institution: $hospital_field\n
Department: $department_field\n
E-Mail: $email_field\n
Tel: $tel_field\n
Wishlist:\n $wish_list";
mail($to, $subject, $body);
echo "Thanks";} ?>

最佳答案

mail接受逗号分隔的配方列表,如 Manual 中所述.所以只需设置 $to

$to = "recipient1@domain.com,recipient2@domain.com";

引用 RFC2822有关有效电子邮件地址规范的更多详细信息。

关于php - 向两个地址发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8939463/

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