Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-21-2012, 12:35 AM   PM User | #1
willscarlet
New Coder

 
Join Date: Aug 2012
Posts: 65
Thanks: 5
Thanked 0 Times in 0 Posts
willscarlet is an unknown quantity at this point
PHP Email script

Hello everyone, I have used this same email script close to a hundred times now on different sites. For whatever reason, this will not send the email to the CC, any suggestions?

PHP Code:
<?php 

$to          
"*************" ;
$cc          "*************" ;
$from          $_REQUEST['name'] ; 
$email          $_REQUEST['email'] ;
$comment    $_REQUEST['comment'] ;

$headers     "From: $from";
$headers     "Cc: $cc"
$subject     "Online Contact Form"

$fields = array(); 
$fields{"name"}         = "Name"
$fields{"email"}         = "Email";
$fields{"comment"}         = "Comment";

$body "We have received the following information:\n\n"
foreach(
$fields as $a => $b)
$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$send mail($to$subject$body$headers);
 
header"Location: *********************" );

?>

Last edited by willscarlet; 12-21-2012 at 01:02 AM..
willscarlet is offline   Reply With Quote
Old 12-21-2012, 01:55 AM   PM User | #2
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,658
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by willscarlet View Post
Hello everyone, I have used this same email script close to a hundred times now on different sites.

PHP Code:
<?php 
$headers     
"From: $from";
$headers     "Cc: $cc"
?>
I'd be surprised if the recipient ever saw who it's from on because you're wiping out the sender on the next line. Try changing = to .= instead but you'll also need the carriage return which typically is \r\n.

To be honest though, I'd just use PHPMailer instead. It's a class you can find via google, include it in your script and it'll make everything a lot easier. You just set the fields you want and tell it to send. It takes care of everything else perfectly. Job done
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:46 AM.


Advertisement
Log in to turn off these ads.