Page 1 of 1

Problems with local routing of email

Posted: Sun 07 Jul 2013 15:45
by David Gibson
Here's another obscure problem with email, which Im documenting here in case its of use to anybody.

I have a web page at bcra.org.uk which, when accessed, uses a PHP program to generate an email message, which it sends to a Mailing List at list.bcra.org.uk. It works fine when accessed via a browser but fails when run as a scheduled task via CRON. The only difference, I can see, is that when accessed via a browser, the user is the Unix value 'unknown', whereas when run as CRON job the user is BCRA. The specific problem is that Mailman refuses to accept the email. Its sits on the server until delivery times out and then it is returned to Sender. The email log shows the delivery attempt as failed, with e message

Child process of mailman_virtual_transport transport returned 1 from command: /usr/local/cpanel/3rdparty/mailman/mail/mailman

A work-around appears to be to send the mail off-site (I use my Gradwell mail forwarding) and then, from there, route it back to the Mailman list on the BCRA site.

What is happening here? Any ideas anyone?

Re: Problems with local routing of email

Posted: Fri 12 Jul 2013 22:24
by David Cooke
Can't immediately see why that shouldn't work

BUT your cron command to launch your php script looks decidedly odd (essentially '> php /home/[path]/test5.html')

Does php process html code well?

I think you should try using curl which will allow you to 'execute' a web page from the shell.

Eg:
> curl http://[path]/test5.html > output.txt

or to silence the output:
> curl -s http://[path]/test5.html

See cookies.curl.eg.sh in your bcra/cron directory.

Re: Problems with local routing of email

Posted: Sun 14 Jul 2013 11:14
by David Gibson
David Cooke wrote:Can't immediately see why that shouldn't work
BUT your cron command to launch your php script looks decidedly odd (essentially 'php [path]/test5.html')
Does php process html code well?
Seems to work OK. I think I once read somewhere that the command line "php some-file-to-parse" requires the PHP code to be encapsulated in tags, from which I inferred that it parses the file just like it would a web page, outputting the html; and indeed that seems to be the case.
David Cooke wrote:I think you should try using curl which will allow you to 'execute' a web page from the shell.
That sounds more sensible. I will try it, and I will add "curl" to my small repertoire of commands. :-)

Re: Problems with local routing of email

Posted: Sun 14 Jul 2013 12:24
by David Gibson
OK. CURL seems to be working. Thanks! I guess the salient point may well be that it is executing as "nobody" , (and presumably taking into account my .htaccess settings although I dont think that's relevant here). Whereas my PHP command (which is still a valid thing to do, I assert :-) ) is executing as BCRA and is "merely" parsing the file for PHP. The important point for me to note (as I have other CRON jobs running PHP files) is, I think, the File Permissions thing - viz: the difference between running as BCRA and running as NOBODY.