简体   繁体   中英

simple mailer with 2 emails to send to

I'm using a simple php mailer script as related to another question i made on here awhile ago.

<?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;
    }
}
?>

how do i add 2 email addresses to send to? I would like to have the mailer to send to 2 separate email addresses

using this :

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

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

to know more about the mail() function plz follow the link http://php.net/manual/en/function.mail.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM