Contact Form Notification Script - Add Add'l Email $mailto's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alsoto
Forum Newbie
Posts: 5
Joined: Tue Mar 20, 2012 8:38 am

Contact Form Notification Script - Add Add'l Email $mailto's

Post by alsoto »

Hello,
I need to be able to have form details sent to additional email addresses. How can I do this? I tried "$mailcc =" but it didn't work for me.
Thanks,
Al

Code: Select all

<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "joe@yahoo.com";
$mailsubj = "Website Form Submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "This is the information that a web visitor entered into a form on the website.:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.yahoo.com/thanks.html\">";
</script>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Contact Form Notification Script - Add Add'l Email $mail

Post by Celauran »

alsoto wrote:I tried "$mailcc =" but it didn't work for me.
What exactly does this mean. Have you tried adding a 'Cc: someone@wherever.com' to the header? Have you tried using a comma-separated list of recipients?

mail()
alsoto
Forum Newbie
Posts: 5
Joined: Tue Mar 20, 2012 8:38 am

Re: Contact Form Notification Script - Add Add'l Email $mail

Post by alsoto »

I tried something like this with no success:

Code: Select all

<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "joe@yahoo.com";
$mailcc = "bob@yahoo.com";
$mailsubj = "Website Form Submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "This is the information that a web visitor entered into a form on the website.:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailcc, $mailsubj, $mailbody, $mailhead); }
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.yahoo.com/thanks.html\">";
</script>
User avatar
TildeHash
Forum Commoner
Posts: 43
Joined: Fri Jul 16, 2010 7:17 am
Location: Apple Valley, California

Re: Contact Form Notification Script - Add Add'l Email $mail

Post by TildeHash »

alsoto wrote:Hello,
I need to be able to have form details sent to additional email addresses. How can I do this? I tried "$mailcc =" but it didn't work for me.
Thanks,
Al

Code: Select all

<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "joe@yahoo.com";
$mailsubj = "Website Form Submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "This is the information that a web visitor entered into a form on the website.:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.yahoo.com/thanks.html\">";
</script>

Code: Select all

$mailhead = "From: $email\n\nReply-To: $email\n\nCc: $mailcc";
Maybe?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Contact Form Notification Script - Add Add'l Email $mail

Post by Celauran »

alsoto wrote:I tried something like this with no success:
You need to look at the function signature. You cannot just randomly add parameters.
Post Reply