PHP form send email to multiple recipients
This will work:
$email_to = "jhewitt@amleo.com,some@other.com,yet@another.net";
PHP Send-Mail form to multiple email addresses
You implode an array of recipients:
$recipients = array('jack@gmail.com', 'jill@gmail.com');
mail(implode(',', $recipients), $submit, $message, $headers);
See the PHP: Mail function reference - http://php.net/manual/en/function.mail.php
Receiver, or receivers of the mail.
The formatting of this string must comply with » RFC 2822. Some examples are:
user@example.com
user@example.com
,anotheruser@example.com
- User
<user@example.com>
- User
<user@example.com>
, Another User <anotheruser@example.com
>
How to send form data to multiple email addresses using PHP?
Add headers
<?php
// Get Data
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$phone = strip_tags($_POST['phone']);
$url = strip_tags($_POST['url']);
$message = strip_tags($_POST['message']);
$headers .="From: Forms <forms@example.net>";
$headers .="CC: Mail1 <Mail1@example.net>";
$headers .=", Mail2 <Mail2@example.net>";
// Send Message
mail( "you@youremail.com", "Contact Form Submission",
"Name: $name\nEmail: $email\nPhone: $phone\nWebsite: $url\nMessage: $message\n",
$headers );
?>
Sending emails to multiple addresses using config PHP file and PHP Mailer
Based on the examples from PHPMailer courtesy of the link shared by @Chris Haas. I made these changes:
<?php
$config = [
"host" => "xxx",
"username" => "xxx",
"password" => "xxx",
"secure" => "ssl", // ssl or tls
"port" => 465,
"sendTo" => "abc@email.com",
"sendTo2" => "efg@email.com",
"sendTo3" => "hik@email.com",
"sendToBCC" => "xyz@email.com",
"from" => "no-reply@email.com",
"fromName" => "Contact Form"
];
And in the sending file I did this:
//Recipients
$mail->setFrom($config['from'], $config['fromName']);
$mail->addAddress($config['sendTo']);
$mail->addAddress($config['sendTo2']);
$mail->addAddress($config['sendTo3']);
$mail->addCC($config['sendToCC']);
$mail->addBCC($config['sendToBCC']);
$mail->addAddress($_POST['email']);
That resolved the issue.
PHP mail: Multiple recipients?
while($row = mysql_fetch_array($result))
{
$addresses[] = $row['address'];
}
$to = implode(", ", $addresses);
As specified on the mail()
manual page, the "to" parameter of the function can take a comma-separated list of addresses.
Related Topics
How to Generate Random Date Between Two Dates Using PHP
Posting JSON Objects to Symfony 2
Laravel Request::All() Should Not Be Called Statically
Expected Response Code 220 But Got Code "", with Message "" in Laravel
Mongodb: Fatal Error: Class 'Mongoclient' Not Found
Using PHP Substr() and Strip_Tags() While Retaining Formatting and Without Breaking HTML
How to Read "Fetch(Pdo::Fetch_Assoc);"
How to Pass Variables Received in Get String Through a PHP Header Redirect
Generating Xml Document in PHP (Escape Characters)
Php: Convert Milliseconds to Date
The Advantage/Disadvantage Between Global Variables and Function Parameters in PHP
Ssl Operation Failed with Code 1: Dh Key Too Small
You Must Enable the Openssl Extension to Download Files via Https
How Exactly Does If($Variable) Work
Is There a PHP Function to Convert a Query String to an Array