Forum Moderators: coopster & phranque

Message Too Old, No Replies

SendMail ignoring Headers?

         

charris

5:18 am on Jun 11, 2003 (gmt 0)



Can anybody help? I wrote a script that emails a users password to them after
they validate some information througha form. The email is sending, but the From: and Subject: headers are being ignored and being printed as part of the message. The script works fine when the data is hardcoded but not when I use the variables.

Here's the code:
$sendmail="/usr/sbin/sendmail/";
$to = $FORM{'to'};
$pwd = $FORM{'pwd'};

open (MAIL, "¦$sendmail -t") ¦¦ die "Can't open SENDMAIL\n";
print MAIL"To:$to\nFrom:$admin\nSubject: $recoverytitle\n\n";
print MAIL"

Here is your reminder: $pwd
You can log in at: $siteaddr/employers
If you did not authorize this request, please contact us immediately.

$tagline

$contactperson
$admindisplay
$sitename
$siteaddress
$sitecsz
Phone:$sitephone1 or $sitephone2
Fax: $sitefax
";
close(MAIL);

jatar_k

8:09 pm on Jun 12, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld charris,

anyone want to help out?

DrDoc

8:30 pm on Jun 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is just a wild guess... But you must have a space after the colon for all headers.

Thus,
To: whatever
not
To:whatever

No clue if that causes the problem or not...

mole

9:30 pm on Jun 12, 2003 (gmt 0)

10+ Year Member



I've always done it like this, which works every time....

# write the e-mail
print MAIL "To: $to_address\n";
print MAIL "From: $from_address\n";
print MAIL "Subject: $subject\n";
print MAIL "$mail_body\n\n";

with some stuff about MAIL=/bin/sendmail or whatever, before.