Dusty
asked on
PHP form mail question
Trying to get this form sent to multiple recipients, I dont know php but shouldnt this work?
function emailFormSubmission()
{
$to = 'me@home.com' . ', ';
$to .= 'you@home.com';
$subject = 'Message from contact form';
-------------------------- ---------- ---------- ---------- -------
the below code works when sending to a single address:
function emailFormSubmission()
{
$to = 'you@home.com';
$subject = 'Message from contact form';
-------------------------- ------
but I need to send to 2 address.
Thanks!
function emailFormSubmission()
{
$to = 'me@home.com' . ', ';
$to .= 'you@home.com';
$subject = 'Message from contact form';
--------------------------
the below code works when sending to a single address:
function emailFormSubmission()
{
$to = 'you@home.com';
$subject = 'Message from contact form';
--------------------------
but I need to send to 2 address.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please don't link to PHPMailer on Worxware; It's not been on there for years. It's now on GitHub.
Secondly, avoid calling mail() yourself. You'll probably be doing it wrong - use a library.
If you're sending the same message to both people, if they know each other, just add both as 'to' recipients of the same message, or CC one of them. If they don't, either use BCC or send two separate messages. There are plenty of code examples in the PHPMailer repo.
Secondly, avoid calling mail() yourself. You'll probably be doing it wrong - use a library.
If you're sending the same message to both people, if they know each other, just add both as 'to' recipients of the same message, or CC one of them. If they don't, either use BCC or send two separate messages. There are plenty of code examples in the PHPMailer repo.
And even if that code would work, the variables you are using will only be 'local', not 'global' and be invisible to any other routines.
ASKER
Thanks!
About multiple emails, you can use PhpMailer or you can iterate through an array:
Trivial example:
Open in new window