Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with mail headers

Status
Not open for further replies.

gxydas

Programmer
Jan 15, 2005
76
0
0
GR
Hi all,

I use PHP 4.3.10 and Apache 2.0.49 (Fedora) in a Linux system.

I use this script to send an email
Code:
mail("someone@somedomain.com", "My Subject”, "Line 1");
When I run this script my webserver occurs a 500 Internal Server Error.
In the server’s errog_log file the below line is being added:
malformed header from script. Bad header=/home/username/dead.letter... S: php-script

This is the contents of dead.letter

From username Tue Jan 10 14:33:03 2006
Return-Path: <username>
Received: (from username@localhost)
by domain.com (8.12.11/8.12.11/Submit) id k0ACX3wX029666;
Tue, 10 Jan 2006 14:33:03 +0200
Date: Tue, 10 Jan 2006 14:33:03 +0200
From: "domain.com" <username>
Message-Id: <200601101233.k0ACX3wX029666@domain.com>
To: someone@somedomain.com
Subject: My Subject

Line 1

Of course domain.com and username are valid.

I see that there is a problem with mail headers but I don’t know what.
Thanks in advance
 
i think the from is badly formed in the header or your default in the php.ini file. it doesnt conform to a valid address.
try:
Code:
$to = ;//valid email address
$subject="test";
$message = test";
$header = 'From: webmaster@example.com';
mail ($to, $subject,$message,$header);
 
Thanks jpadie for your replay.

In the php.ini file these are the lines relative to mail from:
; For Win32 only.
;sendmail_from = me@localhost.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -i

The web server runs on a linux system.

I tried your script but exactly the same error occured.
The dead.letter file contains now:
From username Wed Jan 11 13:42:49 2006
Return-Path: <username>
Received: (from username@localhost)
by domain.com (8.12.11/8.12.11/Submit) id k0BBgnov017586;
Wed, 11 Jan 2006 13:42:49 +0200
Date: Wed, 11 Jan 2006 13:42:49 +0200
Message-Id: <200601111142.k0BBgnov017586@domain.com>
To: valid email address
Subject: test
From: username@domain.com

test




 
try testing sendmail from the command line (i.e. not within php). if this works then you may well have a config or permissions issue.

when you try from the command line sendmail will run as you. when you run through php and a web interface it will run as the nobody user.
 
I need help.

How can I escape to command line and what is the syntax of the command.

Thanks.
 
i'm not a *nix boffin i'm afraid. for the answer to the second question check out
i assume you are using a gui front end to fedora. to get a command line open a terminal window (e.g. bash).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top