PHP Mail Piping and Mailparse Frustration

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

snike

Established Member
Impact
3
I have an email set up to pipe e-mail to a php file. The php file runs great when I do not use mailparse, but when I do it returns "local delivery failed" to the email sender. This is the script I have running:

PHP:
#!/usr/bin/php -q
<?php
ob_start();

$data = '';
$time = time();
$file = fopen('php://stdin', 'r');
while(!feof($file))
{
$data .= fgets($file, 4096);
}

$maild = mailparse_msg_create();
$mime = mailparse_msg_parse($maild,$data);
$struct = mailparse_msg_get_structure($maild);

ob_end_clean();
?>

What can I do to make the script work? Thanks in advance.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
Hi,

The "local delivery failed" message usually means that the MTA could not deliver the message to the pipe.

You said
The php file runs great when I do not use mailparse
what did you mean by that? Did you have a different script that was executing successfully? If so then perhaps you have a PHP error in your current script. Do you have the PECL extensions installed?

How are you configuring the MTA to execute the php script? You could try using:

Code:
|/usr/bin/php -q /full/path/script.php

If you think there may be PHP errors in the script, you could try storing an email in a file, then execute the following:

cat filename | script.php

You should then see whether any errors are produced.
 
0
•••
mailparse is configured and the hashbang (#!/usr/bin/php -q ) executes the php and works great with other scripts.

If you take out
$maild = mailparse_msg_create();
$mime = mailparse_msg_parse($maild,$data);
$struct = mailparse_msg_get_structure($maild);
from the script, it executes fine and does not return anything to the sender.

If you include that mailparse segment and make a error somewhere. like change $struct = mailparse_msg_get_structure($maild); to $struct = mailparse_msg_get_structure($data); it will return a php error in the email sent to the sender.

My host claims that mailparse is set up correctly and that it's a problem with my code. I took this code from PHP: Mailparse Functions - Manual . Am I missing something?
 
0
•••
In that case, the PHP script is erroring out when you have the mailparse lines in. Do you get an error_log file in the same directory as the script? If not, add the following to the top of the script:

PHP:
ini_set('log_errors', 1);

then try again. Check the error_log to see why the script is failing.
 
0
•••
PHP is not logging an error.
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back