简单的邮件,发送2封电子邮件

时间:2012-01-08 04:54:20

标签: php mailer

我使用的是一个简单的php邮件程序脚本,与之前我在这里提出的另一个问题相关。

<?php 
//print_r($_POST);
if(isset($_POST['_save'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $subject = $_POST['subject'];

    if (empty($name) || empty($email) || empty($subject) || empty($message)) {
        if (empty($name))
            $error['name'] = "Please enter your Full Name";
        if (empty($email))
            $error['email'] = "Please enter a valid Email Address";
        if (empty($subject))
            $error['subject'] = "Please Write a Subject";
        if (empty($message))
            $error['message'] = "lease write a message, inquiries or other concerns above";
    }
    else { //if not empty

        $headers="From: {$email}\r\nReply-To: {$email}"; //create headers for email
        mail('email@domain.com',$subject,$message,$headers); //mail the message;
        $success = "Thank you! You're email has been sent.";
        #done;
    }
}
?>

如何添加2个电子邮件地址发送给?我想让邮件发送到2个单独的电子邮件地址

1 个答案:

答案 0 :(得分:2)

使用:

$to  = 'email@domain.com' . ', '; // note the comma
$to .= 'wez@example.com';

mail($to,$subject,$message,$headers); 

要了解有关mail()函数的更多信息,请点击链接http://php.net/manual/en/function.mail.php