Forum Moderators: coopster

Message Too Old, No Replies

need a second set of eyes, php formmail

         

stevebrett

2:06 pm on Nov 4, 2008 (gmt 0)

10+ Year Member



I have problem with a script using jacks php formmail i can seem to resolve, and was hoping a fresh set of eys and brains might get me dislodged.

The page creates an index of employee contacts from a data base, and when you click on the name it looks up the email address and puts it in the hidden recipient form filed ( which is currently sent to text for debugging). The issue is that none of the employees are getting email, even though It generates no errors. However if I put myself in ( at a non g-g-d email address Im getting mail from the form fine). All this leads me to beleive that somehow isp or mail server may be blocking the forms email as spam.

And thinking that through I notice that in the emais that come to me the to field seems malformed I get steve@example.com; steve@example.com ( my email twice seperated by a ;) Any one have an idea as how that happens or if that could perhaps cause email not to be delivered properly

Thanks

Steve

[edited by: jatar_k at 2:15 pm (utc) on Nov. 4, 2008]
[edit reason] no urls thanks [/edit]

jatar_k

4:21 pm on Nov 4, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the first things to look at

see if the message is ending up in a spam/junk folder or what the rules are with the mail server receiving these messages.

In the script take a look for 'To:' in the script, that might get you to the right spot and see what it's doing with the creation of the To field. You could also look at the Mail() function call itself and see if it is creating extra headers. Then look at these headers and see what's going on there.

stevebrett

5:04 pm on Nov 4, 2008 (gmt 0)

10+ Year Member



yes i have them checking the spam angle, but so far nothing.

the To field creation seems pretty routine, its just

$headers .= "To: ".$recipient."\n";

I also changed to form method to get and the email address doesn't appear to be duplicated in the form output

Steve

stevebrett

5:10 pm on Nov 4, 2008 (gmt 0)

10+ Year Member



also i had to add

import_request_variables("gpc");

as register_globals was off by default on this host, im a little out of my element on that so I mention just for completeness

jatar_k

5:20 pm on Nov 4, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what about the mail function call? Does that have anything strange?

you probably need to start dumping variable so you can see what is actually in there.

you can use this at the top to see what is being posted to the script

echo '<pre>';
print_r($_POST);
echo '<pre>';

then you could also echo the variables used in the mail call to see what's going in there

then look at the message source of the email to see what arrived

and then compare

stevebrett

7:53 pm on Nov 4, 2008 (gmt 0)

10+ Year Member



thanks again printing the $_post variables shows nothing unusual

recipient] => steve@example.com
[subject] =>
[require] => email,name,message
[name] => sd
[company] => sd
[email] => steve@example2.com
[phone] =>
[message] => asdasd

The mail function looks this

mail($recipient, $subject, $message, $headers);

and if i echo $ recipient at that point. I get a single address

like this as expected

its thesteve@example.com

[edited by: jatar_k at 8:06 pm (utc) on Nov. 4, 2008]
[edit reason] removed specifics [/edit]

jatar_k

8:07 pm on Nov 4, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what code do they use to set up the $headers before being sent to the mail function?

stevebrett

9:25 pm on Nov 4, 2008 (gmt 0)

10+ Year Member



hers the complete function..

// mail the content we figure out in the following steps
function mail_it($content, $subject, $email, $recipient) {
global $attachment_chunk, $attachment_name, $attachment_type, $attachment_sent, $bcc;
echo $recipient; //sb
$ob = "----=_OuterBoundary_000";
$ib = "----=_InnerBoundery_001";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\n";
$headers .= "To: ".$recipient."\n";
$headers .= "Reply-To: ".$email."\n";
if ($bcc) $headers .= "Bcc: ".$bcc."\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-Mailer: DT Formmail".VERSION."\n";
$headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$ob."\"\n";


echo $headers;

$message = "This is a multi-part message in MIME format.\n";
$message .= "\n--".$ob."\n";
$message .= "Content-Type: multipart/alternative;\n\tboundary=\"".$ib."\"\n\n";
$message .= "\n--".$ib."\n";
$message .= "Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n\n";
$message .= $content."\n\n";
$message .= "\n--".$ib."--\n";
if ($attachment_name && !$attachment_sent) {
$message .= "\n--".$ob."\n";
$message .= "Content-Type: $attachment_type;\n\tname=\"".$attachment_name."\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment;\n\tfilename=\"".$attachment_name."\"\n\n";
$message .= $attachment_chunk;
$message .= "\n\n";
$attachment_sent = 1;
}
$message .= "\n--".$ob."--\n";

mail($recipient, $subject, $message, $headers);


}

jatar_k

5:32 pm on Nov 5, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try using

\r\n

after each line instead of just \n

in other words

replace all \n with \r\n except the one on this line
$headers = "MIME-Version: 1.0\r\n";

because it already has one

stevebrett

2:11 pm on Nov 11, 2008 (gmt 0)

10+ Year Member



Thanks so much for your help on this, Ive tried this suggestion, and have now also tried an alternate form handler to no avail. All changes still send mail to other domains, so Im just throwing it back at them to see if they can find an issue with their exchange server.

Best

Steve