Sending multiple emails

Posted By: TracyJ ()
Posted On: 2004-Apr-20 22:16

As I continue to fumble my way through my first real site using PHP, I have yet another question...

I have many instances on our old site of CGI form processing where the script has to send two different emails out, one to our company and one to the customer. How do I do this in PHP? If I just call the mail() function twice for the two different emails, the second one doesn't get sent.

Thanks again in advance,

Tracy


Posted By: NEntropy ()
Posted On: 2004-Apr-23 19:50

Hmm, you should be able to call mail twice to send two messages. Another possibility is setting 2 email addresses in the 'to' field, separated by comma. I seem to recall it working in PHP's mail function...


Posted By: TracyJ ()
Posted On: 2004-Apr-23 19:55

Problem is, it's two different messages, so I can't just do two email addresses in the 'to' field.

It's not working at all, and when I posted on another forum, someone else said there shouldn't be any problem... and yet... there is! Argh.


Posted By: TracyJ ()
Posted On: 2004-Apr-23 23:50

Finally figured it out. I don't know why it makes a difference, but if I use "return mail()" it doesn't work. If I just call "mail()" it works.


Posted By: NEntropy ()
Posted On: 2004-Apr-25 00:34

Ah, that's because if you do return mail(); then after that command is run, the control of the software goes to the original calling function... Say you have the following code:

1 - function test(){
2 - command
3 - command
4 - return command
5 - command
6 - }

The commands in lines 2, 3, 4 are run, but it never gets to line 5, because the "return" keyword in line 4 will make the script jump over the line 5 and go directly to the original calling command.


Posted By: TracyJ ()
Posted On: 2004-Apr-26 19:29

Gotcha. That makes a lot of sense. Gee, I'm such a newbie! Thanks for helping me figure it out. smile