Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piping emails through cPanel and PHP [closed]

I know that there have been quite a few posts floating around on this subject but I am still stuck it seems.

I have set cPanel up so that any emails that go to [email protected] will be picked up and processed by a PHP script.

Now after much battling I have been able to get it to basically forward the email onto another address yet it is still bouncing the original email back to the sender too which seems weird to me. Here is the script that I use:

#!/usr/bin/php -q
<?php

$fd = fopen("php://stdin", "r");

$email = '';

while(!feof($fd))
{
    $email .= fread($fd, 1024);
}

fclose($fd);
mail('[email protected]', 'test', $email);
?>

And I have also tried to control the issue with output buffering and yes before you ask the script is chmod'd to 755...

Any help really would be appreciated as it is starting to annoy me now.

like image 849
Marc Towler Avatar asked Nov 04 '22 17:11

Marc Towler


1 Answers

Most likely it has been malfunctioning email server in your service provider. PHP does spot if there is no mail daemon running and gives appropriate error, but it can’t do any proper error checking about mail actually delivered: after all, it might fail after a day or two and user naturally won’t wait all that time for the script to end.

Postfix updates for example often requires some care as it takes new configuration into use automatically. Or Dovecot has been updated and not restarted and it will refuse to do anything because of that by default.

like image 141
Smar Avatar answered Nov 09 '22 14:11

Smar