Forum Moderators: coopster
the mail() function works fine if I run it from the command line (php mailtest.php) however if I load it up in my web browser it says "can't send email". I've included the code below
<?
if(mail($to,$subject,$message))
echo "<h4>sent email</h4>";
else
echo "<h4>can't send email</h4>";
?>
Any Ideas?
You don't need to define it outright, since PHP trusts sendmail to do its job. When you configured and installed PHP, it found where the sendmail executable is, and will use that one.
running [...] on mandrake 7.2
MattyMoose said, "(I'm assuming you're working on a *NIX system).
MattyMoose, your assumption seems to be correct. hehe ;)
<edit>
OK, I apologize, I see there is a Linux for Windows which includes the fundamental functionality of Linux-MandrakeTM 7.2...seems goofy to me though -- I mean, if you're going to use Linux, use Linux. Why drop it on a Windows platform? Never mind, I don't care and I don't want this to get off topic...
</edit>
And you are also right regarding SMTP. manofwax, the SMTP configuration directive [php.net] is used under Windows only.
[edited by: coopster at 11:41 pm (utc) on Aug. 18, 2004]
MattyMoose, your assumption seems to be correct. hehe ;)<edit>
OK, I apologize, I see there is a Linux for Windows which includes the fundamental functionality of Linux-MandrakeTM 7.2...seems goofy to me though -- I mean, if you're going to use Linux, use Linux. Why drop it on a Windows platform? Never mind, I don't care and I don't want this to get off topic...
</edit>
<OT>
Hay! I nevur sez I wuz smahrt or eneethingh!
That does seem pretty goofy to me too...
</OT>
Our PHP Library [webmasterworld.com] has some good stuff, including Learning PHP - Books, Tutorials and Online Resources
The Authoritative List [webmasterworld.com]
And hey, welcome to WebmasterWorld.
What do your apache log files say? Also, what does your general syslog say? Check both /var/log/messages and /var/log/maillog when you try the script both from command line and web.
Thanx for pointing me in the right direction ("when in doubt view the logs").
It's a permision issue, syslog reports:
sendmail[15623]: i7JDlOt15623: SYSERR(apache): Can't create transcript file ./xfi7JDlOt15623: Permission denied
sendmail[15623]: i7JDlOt15623: SYSERR(apache): Cannot create ./dfi7JDlOt15623: Permission denied
sendmail[15623]: i7JDlOt15623: from=apache, size=0, class=0, nrcpts=0, relay=apache@localhost
how do I rectify.
"What do your apache log files say? Also, what does your general syslog say? Check both /var/log/messages and /var/log/maillog when you try the script both from command line and web."
============================
i'm wondering how you run the mail() function from the ocmmand line. Thanks a lot.
Kev. Kev.
all that's running on this box now is web service and a backup of a pgsql DB. Would changing the owner of the mqueue break anything from root.mail to root.apache (I did that and it works) or could I do something else to put mail and apache in a group and change ownership to that group?
And yeah I run it from the command line as root
You can't go up to 4.3.8? :) I'd think that you should upgrade your code to work with the latest PHP, since PHP is going to continually evolve, and your code is just going to get more and more out of sync, and more and more of a nightmare when you finally move to a server that is running a later version.
> Would changing the owner of the mqueue break anything from root.mail to
> root.apache (I did that and it works)
Don't know, really... Try it for a few days and see what happens. :)
> And yeah I run it from the command line as root
That explains it working from the command line.