Need help with Headers

Hello.
I have been using a form handler on my website. I have a new domain and have copied the php form handler to it, with minor tweaks (the domain for the email address is different, etc). The problem is, the “cc” part of the header is not working on the new site. (It still works fine on the other one).
Can you help me figure out what’s missing? Thanks!

[php]<?php
$subject = ‘Sign Me Up’;
$emailadd = ‘[email protected]’;
$url = ‘confirmation.html’;
$req = ‘1’;

$text = “Results from form:\n\n”;
$space = ’ ';
$line = ’
‘;
foreach ($_POST as $key => $value)
{
if ($req == ‘1’)
{
if ($value == ‘’)
{echo “$key is empty”;die;}
}
$j = strlen($key);
if ($j >= 20)
{echo “Name of form element $key cannot be longer than 20 characters”;die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ’ ‘;}
$value = str_replace(’\n’, “$line”, $value);
$conc = “{$key}:$space{$value}$line”;
$text .= $conc;
$space = ’ ';
}
$headers = ‘Cc: [email protected]’ . “\r\n”;
mail($emailadd, $subject, $text, ‘From: ‘.$emailadd.’’, $headers);

$email = $_POST[‘Email’];
$subject = ‘We will be in contact with you shortly’;
$text = 'Dear Business Owner,

Your request for more information has been received. One of our representatives will be in contact with you shortly!’;
mail($email, $subject, $text, ‘From: ‘.$emailadd.’’);

echo ‘’;
?>
[/php]

What gives? Why would the “cc” function work on one website and not another?

Different PHP versions and or environments.

How can I tell which PHP versions are provided by my hosting service? …and if that is the case, what do I do?

[php]<?php

echo phpinfo();

?>[/php]

I contacted both hosts and they confirmed that both support PHP 5.2. ANy other ideas?

one might use a different mail system then the other, meaning one might filter it while the other let’s it through.

…the CC on both handlers goes to the same email address, so do you mean hosting site uses a different mail system or are you referring to the email hosting service?

mail system

What’s up with this line???

mail($emailadd, $subject, $text, ‘From: ‘.$emailadd.’’, $headers);

Adding nothing to the emailadd? SO, you have a header sent (From:) and a space and some other headers.
That can not be done. You can do this if the headers are formatted correctly. My guess is that you should be sending it like this:

mail($emailadd, $subject, $text, “From: ‘.$emailadd.’”, $headers);

or:

mail($emailadd, $subject, $text, 'From: '.$emailadd, $headers);

good catch, I was thinking it had something to do with how the mail system process’s email, my own email server likes to strip as the only reason for those is a virus attack.

I apologize. The the real text says

mail($emailadd, $subject, $text, “From: BOSSES NAME ‘.$emailadd.’”, $headers);

…i excluded it from the post of anonymity.

To be clear, I’ve used the same scripting (only changing a domain email address for each) on 3 separate websites. The original, hosted by Earthlink and two others both hosted by GoDaddy. The earthlink works flawlessly, one of the Godaddy’s works as well it’s just the newest GoDaddy hosted one that isn’t working.

Again, the only thing that I’ve changed is the domain name of $emailadd for each website. I can’t figure out why it’d work for one and not the other.

Well, perhaps the new domain name is spelled incorrectly or has been flagged as a bad site.
Perhaps it could be a problem with the server. I do not see anything that would work on one site and not on another.

So, if you remove the CC, it works okay? Looking at your code you only have the CC: as a header. Here is a sample from PHP.Net’s mail section showing a sample of how to set up headers. Perhaps you need to put more into your header to make it more standard. Not sure if it will help, but, don’t know what else to suggest…

[php]
// To send HTML mail, the Content-type header must be set
$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;

// Additional headers
$headers .= ‘To: Mary [email protected], Kelly [email protected]’ . “\r\n”;
$headers .= ‘From: Birthday Reminder [email protected]’ . “\r\n”;
$headers .= ‘Cc: [email protected]’ . “\r\n”;
$headers .= ‘Bcc: [email protected]’ . “\r\n”;

// Mail it
mail($to, $subject, $message, $headers);
[/php]
One further note, I picked this sample to show you because it sends emails in the TO: section to two addresses. Perhaps you could just use that method or even the Bcc: … Hope you figure it out…

Thanks…I will try your TO suggestion and see if it works.

When the form is tested, there isn’t an error. I simply never receive the CC email. The email does go to the “TO” person though, so Im hoping your suggestion works.

THanks!

One more thing… Perhaps the email which is CC’d to you is ending up in the junk email bin.
It might be your SPAM-Filter dumping it. I have seen that happen, too… Good luck!

Yay! It works. Thanks!!!

Well, congrats on getting a work-around! Still puzzled why the original didn’t work.

See you in the bitstream… (That’s really all this is… LOL! )

Sponsor our Newsletter | Privacy Policy | Terms of Service