Jump to content

COde for a Cc


RON_ron

Recommended Posts

I think the problem might be here:

 

 

$headers .= "Cc: $tf\r\n";

 

Assuming your email address has the '@' which is a reserved character in PHP, it's possibly being interpreted by PHP.

 

Maybe this will fix it:

 

$headers .= 'Cc: ' . $tf . "\r\n";

 

Notice where I used single quotes vs. double quotes -- it's very important to the end result.

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935721
Share on other sites

:( still it's the same. I think the problem is in here.

 

$to = "$email";

$headers = "From:" .$tf."\r\n";

$headers .= 'Cc: ' . $tf . "\r\n";

$subject = "SUBJECT";

$message = "bla bla bla..."; 

$message = "Name: " . $thename; 

 

$sentOk = mail("$tf, $email",$subject,$message,$headers);

echo "sentOk=" . $sentOk;

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935727
Share on other sites

Yeah, I didn't even look carefully at that, but that's not how you pass parameters.  should be:

 

 

$sentOk = mail($to, $subject, $message, $headers);

 

 

In the future, more information is better.  I assumed that your emails were actually going out, since you stated that the problem was in the Cc: when in fact the entire email was not being sent.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935733
Share on other sites

Have you put in some debug code that echos or print_r's your variables prior to the call to mail()?  Are these what you expect them to be?  What are the values of $to, $subject, $message, $headers?

 

Let's see the current version of the code you have as well.

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935748
Share on other sites

The full server side script

 

<?PHP

//my original mail$to = "[email protected]";

 

$subject = "$thecompany request";

$headers = "From:" .$email."\r\n";

$message = "Name: " . $thename;

$message .= "\nCompany or Club Name: " . $thecompany;

$message .= "\nAddress: " . $theaddress;

$message .= "\nRequired Date: " . $thedate;

$message .= "\nPhone: " . $phone;

$message .= "\nEmail: " . $email;

 

$sentOk = mail("$to",$subject,$message,$headers);

echo "sentOk=" . $sentOk;

 

//delaer and clients duplicate emails

$to = "$email";

 

$subject = "Thank you...";

$headers = "From:" .$tf."\r\n";

$headers .= 'Cc: ' . $tf . "\r\n";

$message = "thank you....";

$message = "Name: " . $thename;

$message .= "\n\nCompany or Club Name: " . $thecompany;

$message .= "\n\nAddress: " . $theaddress;

$message .= "\n\nRequired Date: " . $thedate;

 

$sentOk = mail($to, $subject, $message, $headers);

echo "sentOk=" . $sentOk;

 

?>

 

My requirement is

ORIGINAL mail - only to me (no one will see it).

Duplicate mails - to the dealer & client with less info and different message + heading.

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935750
Share on other sites

Ok, so let's try and clean this up, and then I'll ask questions:

//my original mail
$to = '[email protected]';

$subject = "$thecompany request";
$headers = 'From:' . $email . "\r\n";
$message = "Name: " . $thename;   
$message .= "\nCompany or Club Name: " . $thecompany;
$message .= "\nAddress: " . $theaddress;
$message .= "\nRequired Date: " . $thedate;
$message .= "\nPhone: " . $phone;
$message .= "\nEmail: " . $email;

$sentOk = mail($to, $subject, $message, $headers);
echo "sentOk= $sentOk";

//delaer and clients duplicate emails
$to = $email;

$subject = "Thank you...";
$headers = 'From:' .$tf . "\r\n";
$headers .= 'Cc: ' . $tf . "\r\n";
$message = "thank you....";   
$message = "Name: " . $thename;   
$message .= "\n\nCompany or Club Name: " . $thecompany;
$message .= "\n\nAddress: " . $theaddress;
$message .= "\n\nRequired Date: " . $thedate;

$sentOk = mail($to, $subject, $message, $headers);
echo "sentOk= $sentOk";
?>

 

So, now the question -- is this the *entire* script?  Where are the values of the variables coming from -- I don't see you getting them from a $_POST or $_GET.  Is this because you're using register_globals?

 

At any rate, I don't see where the value of $tf is set.  If it has no value, obviously things won't work.  This is why I suggessted for debugging you echo out the values for example:

 

echo '$to-> ' . $to . '
';
echo '$subject-> ' . $subject . '
';
echo '$message-> ' . $message . '
';
echo '$headers-> ' . $headers . '
';

$sentOk = mail($to, $subject, $message, $headers);
echo "sentOk= $sentOk";

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935763
Share on other sites

Are you using the cleaned up version I provided, that removed some of the stuff that wasn't required? 

 

You also never provided info about the operating system and MTA you are using. 

 

Does email #1 get sent?

 

Does email #2 get sent, and if so what are the email headers.

 

This is all important diagnostic info, that only takes a minute to determine.

Link to comment
https://forums.phpfreaks.com/topic/177463-code-for-a-cc/#findComment-935884
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.