Problems with local routing of email

Discussion about BCA's Internet Hosting Service
User avatar
David Gibson
Posts: 479
Joined: Thu 16 Mar 2006 23:45

Problems with local routing of email

Post by David Gibson » Sun 07 Jul 2013 15:45

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?

David Cooke
Site Admin
Posts: 299
Joined: Thu 29 Dec 2005 23:22
Location: Axbridge, Somerset, UK

Re: Problems with local routing of email

Post by David Cooke » Fri 12 Jul 2013 22:24

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.
Last edited by David Gibson on Sun 14 Jul 2013 12:25, edited 2 times in total.
Reason: removed confidential file path information
Dave Cooke
BCA IT Working Party, BCA Web Services, National Cave Registry Co-ordinator, CSCC Webmaster

User avatar
David Gibson
Posts: 479
Joined: Thu 16 Mar 2006 23:45

Re: Problems with local routing of email

Post by David Gibson » Sun 14 Jul 2013 11:14

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. :-)

User avatar
David Gibson
Posts: 479
Joined: Thu 16 Mar 2006 23:45

Re: Problems with local routing of email

Post by David Gibson » Sun 14 Jul 2013 12:24

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.

Post Reply