Page 1 of 1

webmail / $toaddress issue

Posted: Mon Oct 12, 2009 3:38 am
by edawson003
I want a registration confirmation email to go out to the user and myself. Couldn't find much on the web on how to send to multiple email addresses via webemail. Did find something that utized bcc: via a $headers variable. Though, for some reason it didn't work. What am I doing wrong?

Code: Select all

 
$toaddress = $_POST['email'];
   $subject = 'Welcome';
   $mailcontent = 'Welcome '.$fname."\n\n"
   .'Your username is: '.$_POST['username']. "\n"
   .'message message message.'."\n";
   $headers = 'From: newaccounts@myurl.com';
   $headers .= "Bcc: edawson003@myurl.com\n";
   mail($toaddress, $subject, $mailcontent, $headers);
 
I also tried this $toaddress = $_POST['email'] && ';edawson003@myurl.com';

Re: webmail / $toaddress issue

Posted: Mon Oct 12, 2009 3:44 am
by onion2k
The obvious solution is just to send two separate emails... eg

Code: Select all

mail($toaddress, $subject, $mailcontent, $headers);
mail("edawson003@myurl.com", $subject, $mailcontent, $headers);
If you really want to send the email to multiple recipients though, look at SwiftMailer (swiftmailer.org) .. it's a fantastic mailing library that does everything mail related properly according to the RFC email specs.

Re: webmail / $toaddress issue

Posted: Mon Oct 12, 2009 8:36 am
by edawson003
Oh, yeah. Pretty obvious now that I think about it. :oops: Thanks!