webmail / $toaddress issue

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

webmail / $toaddress issue

Post 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';
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: webmail / $toaddress issue

Post 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.
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Re: webmail / $toaddress issue

Post by edawson003 »

Oh, yeah. Pretty obvious now that I think about it. :oops: Thanks!
Post Reply