mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* Re: [ptxdist] PTXdist PHP5 CLI mail()
       [not found] <mailman.9.1371204002.4501.ptxdist@pengutronix.de>
@ 2013-06-14 10:57 ` Dennis.Herbrich
  2013-06-14 11:15   ` Dave Festing
  0 siblings, 1 reply; 4+ messages in thread
From: Dennis.Herbrich @ 2013-06-14 10:57 UTC (permalink / raw)
  To: ptxdist

dave_festing@hotmail.com wrote:

>  Have been struggling with trying to get PHP's mail() to work [...]
> Appreciate any suggestions as to the apparently fundamental mistake
> I am making.

The fundamental mistake is not checking the debug log output to find the
real reason *why* the call to mail() fails. Crank up the log level for 
PHP,
and see what it tells you. You might be having no sendmail binary in the
expected path, or some other file system permission problem that prevents
mail() to do it's job.

What you may not know is that PHP's mail() function usually uses an
external binary ("/usr/bin/sendmail") to drop the mail into the locally
running, completely independent MTA. This obviously allows for many things
to go wrong on the way. Check the PHP debug log, then the MTA's logs if
delivery somehow fails.

No MTA running locally? Try using PHP's SMTP features directly with a 
remote
MTA instead, or install a simple forwarding MTA, depending on your
requirements.

In either case, this is much more of a PHP/MTA configuration issue,
and likely nothing ptxdist-specific.

Best regards,
  Dennis

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ptxdist] PTXdist PHP5 CLI mail()
  2013-06-14 10:57 ` [ptxdist] PTXdist PHP5 CLI mail() Dennis.Herbrich
@ 2013-06-14 11:15   ` Dave Festing
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Festing @ 2013-06-14 11:15 UTC (permalink / raw)
  To: ptxdist

 <Dennis.Herbrich@...> writes:

> 
> dave_festing@... wrote:
> 
> >  Have been struggling with trying to get PHP's mail() to work [...]
> > Appreciate any suggestions as to the apparently fundamental mistake
> > I am making.
> 
> The fundamental mistake is not checking the debug log output to find the
> real reason *why* the call to mail() fails. Crank up the log level for 
> PHP,
> and see what it tells you. You might be having no sendmail binary in the
> expected path, or some other file system permission problem that prevents
> mail() to do it's job.
> 
> What you may not know is that PHP's mail() function usually uses an
> external binary ("/usr/bin/sendmail") to drop the mail into the locally
> running, completely independent MTA. This obviously allows for many things
> to go wrong on the way. Check the PHP debug log, then the MTA's logs if
> delivery somehow fails.
> 
> No MTA running locally? Try using PHP's SMTP features directly with a 
> remote
> MTA instead, or install a simple forwarding MTA, depending on your
> requirements.
> 
> In either case, this is much more of a PHP/MTA configuration issue,
> and likely nothing ptxdist-specific.
> 
> Best regards,
>   Dennis
> 
> 
Dennis,

I should have stated that I am running msmtp as the local MTA.  I keep an
eye on the log files.  The main issue with mail() is that it doesn't return
useful error messages.  With the CLI version I get a mail.log message that
confirms that mail() has been sent, whilst with the web-based version there
is no such indication plus no PHP_errors either.

PHPmailer as least returns some information.

As long as there is nothing wrong with using PHP with CLI enabled in PTXdist
2012.12.0 for my web-page requirement I will look elsewhere.  I will read up
on your suggestions.

Thank you,
Dave 




-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ptxdist] PTXdist PHP5 CLI mail()
  2013-06-14  9:20 Dave Festing
@ 2013-06-20 10:04 ` Dave Festing
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Festing @ 2013-06-20 10:04 UTC (permalink / raw)
  To: ptxdist

Just for anyone who ends up here, the solution was to change the thttpd
start script to -u /the/directory/where/the/webpages/actually/are/located

Seems some things worked OK, just not system(), exec() and mail() when -u
didn't point to the webpage directory.

Even though safe-mode was off it seems like there was still a restriction on
the exec family of functions.

http://www.php.net/manual/en/features.safe-mode.php
http://www.php.net/manual/en/features.safe-mode.functions.php


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ptxdist] PTXdist PHP5 CLI mail()
@ 2013-06-14  9:20 Dave Festing
  2013-06-20 10:04 ` Dave Festing
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Festing @ 2013-06-14  9:20 UTC (permalink / raw)
  To: ptxdist

Have been struggling with trying to get PHP's mail() to work in PTXdist
2012.12.0

I can send email using PHP-CLI as follows:

#!/usr/bin/php5

<?php
mail('your_name@hotmail.com', 'Alarm!!', "High temperature", "From:
my_name@clear.net.nz \r\n");
?>

But, when I try to send email from within a PHP block in a webpage the mail
function does not run:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> Test mail function
</title>
</head>

<body>
<h2>Test mail function</h2>

<?php
if(mail('your_name@hotmail.com', 'Alarm!!', "High temperature", "From:
my_name@clear.net.nz \r\n"))
{
  echo "mail was sent";
}
else
{
  echo "there were errors";
}
?>

</body>
</html>

These both are in the same directory, same permissions and use the same
php.ini file.

In the rule file php5.in and for PHP5_SAPI_CLI the help states:
Build CLI (command line version) of PHP.

Does this mean one ends up with an unique version of PHP that has the added
feature of running CLI or does it mean that if you want to have a "normal"
version of PHP to use in webpages then you have to build a version without CLI?

The CLI version I ended up with seems to work in both BUT not for the mail()
function!

I have also tried PHPmailer and get an error:
Mailer Error: Could not instantiate mail function. 
This confirms to me that the mail() just does not run on the webpage.

Appreciate any suggestions as to the apparently fundamental mistake I am making.

Thanks,
Dave






-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-20 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.9.1371204002.4501.ptxdist@pengutronix.de>
2013-06-14 10:57 ` [ptxdist] PTXdist PHP5 CLI mail() Dennis.Herbrich
2013-06-14 11:15   ` Dave Festing
2013-06-14  9:20 Dave Festing
2013-06-20 10:04 ` Dave Festing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox