Return to Help Center

Welcome to the Bravenet Help Forums. Here you can chat and meet other Bravenet Members. Please do not post advertisements.

Forum: Coding Discussions
This forum is locked and posting is not allowed
Author
Comment
php coding - how to code for multiple email recepients

I have two questions:

After much tweaking I was finally able to get the php script correct so that a form can be sent to me. Now I would like to know what I need to do so that I can have the form sent to me AND to one other email at the same time. My script looks something like this:


/* Subject and email variables */

$emailSubject = 'Form!';
$webMaster = 'myemailaddress@internetprovider.net';
$email = 'noreply@mywebsite.com';

I have tried to insert another email address using just a comma after the first address - tried this in many different configurations and I can't get it to work. Anyone out there that can tell me what I need to add to my code? Also, if I decided to send it to three people, what would that look like?

Question 2: Is it possible to include code that would send the form to me, send it to one other person and to automatically download a copy of the completed form to the computer of the person completing the form?

Thank you!

Email  
Re: php coding - how to code for multiple email recepients

Not sure if you still need this, but I'll answer in case anyone else does.

Sending mail to multiple recipients depends on both the method you're using to send the mail, and the server configuration.

If you're using php mail() it should work with the comma, or you can add a "CC:" or "BCC:" header to make it work (see http://php.net/manual/en/function.mail.php)

The server may be configured to only allow one recipient, in which case you need to repeat the code used to send it, but change the email address.

If you want to set it to automatically download, assuming the page has no other output then you can set the page header to force downloading as an attachment, set a file name, then everything that is echo'd will make up the contents of the file.
Check out this page:
http://www.ryboe.com/tutorials/php-headers-force-download
But change the Content-Type header to "text/plain", and instead of readfile() you just echo the contents of the form.
It'll take a bit of tweaking to get it to work though.

Note that just because you request it to be downloaded, it may not be. Some browsers (not the main ones as far as I know) may ignore the request to treat it like a download, and even if they don't the user may not choose download it.

Hope this helps
-Scut

Email  
Re: php coding - how to code for multiple email recepients

Have you tried the following:

&& or ||

Since I am guessing its inside an Echo, these might work.

in regards to saving a copy... Waste of time personally. Who who ever want a copy saved on their computer...