Function 向两个用户发送确认电子邮件

Function 向两个用户发送确认电子邮件,function,parameters,php,Function,Parameters,Php,我正试图发送一封确认电子邮件给两位会员,但我不知道该怎么做。以下仅为相关代码。 我以前在我的网站上使用过PHP邮件作为联系人页面,这很好,但我不知道如何将其发送给多个人。你能告诉我我做错了什么吗 功能交换: //full code for exchange not included // Redirect to index page if exchange is successful if ($success){ sendMail($coinsAvail['Email']

我正试图发送一封确认电子邮件给两位会员,但我不知道该怎么做。以下仅为相关代码。 我以前在我的网站上使用过PHP邮件作为联系人页面,这很好,但我不知道如何将其发送给多个人。你能告诉我我做错了什么吗

功能交换:

 //full code for exchange not included

// Redirect to index page if exchange is successful  
if ($success){
        sendMail($coinsAvail['Email'],$valueResultAdd['Email'],$valueResultAdd['OddJobName']);
        header("location: index.php?success=yes&email={$valueResultAdd['Email']}");
    }
        else{
            if($success)
             header("location: index.php?success=no&email={$valueResultAdd['Email']}");
        }
        exit();

function to send email
    }
    //Send a confirmation email to both members
    function sendMail($purchaseEmail, $oddjobEmail, $oddJobName)
    {
        $to = "$purchaseEmail, $oddjobEmail";
        $subject = "$oddJobName";
        $message = "Hello! $oddJobName has been requested by $purchaseEmail.";
        $from = "someonelse@example.com";
        $headers = "From:" . $from;
        mail($to,$subject,$message,$headers);
        echo "Mail Sent.";  
    }

谢谢您的帮助。

假设$coinsAvail['Email']和$valueResultAdd['Email']都是电子邮件地址,那么这应该行得通。我会用回音($to);在函数中,确保$to字符串的外观符合您的要求。

假设$coinsAvail['Email']和$valueResultAdd['Email']都是电子邮件地址,则应该可以使用。我会用回音($to);在函数中,确保$to字符串的外观符合您的要求。

根据

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

user@example.com user@example.com, anotheruser@example.com使用者 用户,另一个用户

因此,在您的情况下,您可以这样做:

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

mail($to, 'the subject', 'the message', null,
   '-fwebmaster@example.com');
?>

根据

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

user@example.com user@example.com, anotheruser@example.com使用者 用户,另一个用户

因此,在您的情况下,您可以这样做:

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

mail($to, 'the subject', 'the message', null,
   '-fwebmaster@example.com');
?>


要发送给很多人,只需使用“逗号”分隔符,就像你通过yahoo,gmail帐户向多人发送电子邮件一样。要发送给很多人,只需使用“逗号”分隔符,就像你通过yahoo,gmail帐户向多人发送电子邮件一样。