Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top