LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2004, 12:36 AM   #1
slackarse
LQ Newbie
 
Registered: Oct 2004
Posts: 5

Rep: Reputation: 0
php mail question


Hi,

I have a problem where php won't send e-mail when the php page is accessed via a browser.

Sendmail works fine from the command line, the php script even works fine from the command line using php -f testmail.php.

I have a script, a simple script, to test it out:

PHP Code:
<?php

$email 
"myemail@anotherisp.com";
$subject "This is the subject";
$msg "This is the message";
$from "From: [email]myemail@myisp.com[/email]";

if (
mail($email,$subject,$msg$from)) {
  echo 
"success!!\n<br>";
} else {
  echo 
"failed\n<br>";
};

?>
When I run it from the linux command line, I get the output:

success!!

When I try to access it via a browser, I get:

failed

Anyone know what's going on?
My last remaining theory is a permissions problem somewhere.
 
Old 10-07-2004, 01:58 AM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
What happens if you su to the apache user before running the script?
 
Old 10-07-2004, 02:05 AM   #3
slackarse
LQ Newbie
 
Registered: Oct 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Ahh ... genius ...

can not chdir(/var/spool/mqueue/): Permission denied
Program mode requires special privileges, e.g., root or TrustedUser.
failed
 
Old 10-07-2004, 02:23 AM   #4
slackarse
LQ Newbie
 
Registered: Oct 2004
Posts: 5

Original Poster
Rep: Reputation: 0
hmm ... now what's the most secure way to give apache permissions to the mqueue directory?
 
Old 10-07-2004, 02:54 AM   #5
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
I get the impression that permissions on that directory shouldn't be changed, but rather your mail server should be configured to accept mail from apache (I think this is why you see the mention of 'TrustedUser')
 
Old 10-07-2004, 05:52 AM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Did you try add \r\n to the from field ?

PHP Code:
mail($email$subject$msg"$from\r\n"); 
 
Old 10-07-2004, 05:55 AM   #7
slackarse
LQ Newbie
 
Registered: Oct 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Yeh, but it's a permissions problem.

I need to find out how to allow apache's user (default: nobody) as a trusted user.
I tried editing the trusted-users file, but that didn't work either.
 
Old 10-07-2004, 06:32 AM   #8
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Did you restart your mail server after editing that trusted users file? That sounds like the right thing to do (not sure what mail server you're running).
Don't forget to test from the command line as apache, in case there is some other error occurring (whack-a-mole style )
 
Old 10-07-2004, 06:34 AM   #9
slackarse
LQ Newbie
 
Registered: Oct 2004
Posts: 5

Original Poster
Rep: Reputation: 0
I am using sendmail, but I don't run it as a daemon, as the server is only used to send email (relaying), not receiving mail.
 
Old 10-07-2004, 06:48 AM   #10
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
See if the instructions here help you out: http://lists.debian.org/debian-isp/2.../msg00231.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php mail() fails bullshit Programming 0 09-04-2005 11:47 AM
PHP Website with e-mail forms, what mail daemon? gbkyle Linux - Software 1 07-05-2005 12:33 PM
php: different mail server from php.ini rayds Programming 0 09-14-2004 03:48 AM
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 06:06 PM
php + mail jogurt666 Programming 4 01-05-2004 02:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration