Jump to content

Recommended Posts

Posted

I'm currently working on a mailing list for my website. I need this list to be quite customized, so I don't want to use a pre-made script. Anyway, I want to make some sort of bounce back e-mail filter that can "read" bounced e-mails and automatically remove their address from the database.

 

I thought about using an e-mail filter for this, but I'm not quite sure what to do. Anyone have any links/scripts or any ideas about how to go about this?

 

Thanks for any help you can give!

Posted

Sorry...I don't know of any right off-hand. Since you said it needs to be customized (and if it's not time-critical), might I suggest starting with a general script from somewhere like hotscripts and play around with it until you get exactly what you're looking for?

 

Hopefully some other family member will chime in with something a little more definitive.

Posted

Yea, I'm not in any rush or anything. This is just for my own personal site. If I can't get a solution, I'll probably do that. I just wondered if anyone knew a quick way to do it.

Posted

I've decided to try and use the e-mail filter in cpanel, but I'm having a bunch of problems with it. Here's what I have so far...

 

The PHP code:

>#!/usr/bin/php
<?
mail("kevin@****","Working...","It worked!");
?>

 

I also set up the filter destination to |/home/mycpanelusername/public_html/myfile.php

 

Unfortunatly, I keep getting bounced e-mails. Here's an excerpt of an error e-mail I get:

>This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

 pipe to |/home/mycpanelusername/public_html/myfile.php
   generated by someone@****
   local delivery failed

 

Any ideas what's wrong?

Guest helpbytes
Posted

I've been trying to do this too and getting the same error.

Posted

Nope, it still won't work for me. I changed the opening statement and made sure it had permissions set to 755, but I still get the same error. Any chance this has to be in a specific directory to work?

Posted
Nope, it still won't work for me. I changed the opening statement and made sure it had permissions set to 755, but I still get the same error. Any chance this has to be in a specific directory to work?

The script does not need to be in a specific directory.

 

I set up an e-mail account, created a filter script, and added the script as an e-mail filter in CPanel. I tested various things, and the only thing I encountered that caused an error like what you're seeing to be e-mailed was for the script to not explicitly return a '0' at the end of the script (to indicate the script executed with no errors).

 

This is essentially the script I tested that worked for me:

>#!/usr/bin/php -q
<?php
mail("tweezerman@xxxxxxxxx.com","Working...","It worked!");
return 0;
?>

From what I've read on Google, the "local delivery failed" text in your error message is an indication that 1) your script had an error when it was run, 2) it did not return '0' when it was finished, or 3) the script inadvertantly produced output on STDOUT or STDERR, which can be interpreted as an error even if the script exits with a return value of '0'.

 

Hope this helps...

Guest helpbytes
Posted

I don't use a return 0; and it works, but you must ensure you have the -q switch on the first line, otherwise php outputs some data to the shell which you dont want, it will generate an error with the php header output as the error message.

Posted (edited)

I feel like I've tried everything, and it still doesn't work. I used TCH-David's code, with the -q added, and I get this e-mailed error message:

 

>pipe to |/home/mycpanelusername/public_html/myfile.php
   generated by newsletter@***
   local delivery failed

The following text was generated during the delivery attempt:

------ pipe to |/home/mycpanelusername/public_html/myfile.php
      generated by newsletter@**** ------

Error in argument 1, char 3: option not found
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>] 
      php <file> [args...]
 -a               Run interactively
 -C               Do not chdir to the script's directory
 -c <path>|<file> Look for php.ini file in this directory
 -n               No php.ini file will be used
 -d foo[=bar]     Define INI entry foo with value 'bar'
 -e               Generate extended information for debugger/profiler
 -f <file>        Parse <file>.  Implies `-q'
 -h               This help
 -i               PHP information
 -l               Syntax check only (lint)
 -m               Show compiled in modules
 -q               Quiet-mode.  Suppress HTTP Header output.
 -s               Display colour syntax highlighted source.
 -v               Version number
 -w               Display source with stripped comments and whitespace.
 -z <file>        Load Zend extension <file>.

 

I tried taking out the space and typed #!/usr/bin/php-q and I get the same error as before. The file is set to 755 permissions. Think this might be something I need to take up with the support dept?

Edited by flashisland
Posted (edited)

Well, it kind of works now. I changed the pipe to address to this:

 

>|/usr/bin/php /home/mycpanelsusername/public_html/myfile.php

 

My php code is this:

>#!/usr/bin/php -q
<?php
mail("kevin@****","Working...","It worked!");
return 0;
?>

 

Now I do recieve the working email, but I still get a bounced back error message! Here's the error message:

>This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

 pipe to |/usr/bin/php /home/mycpanelusername/public_html/myfile.php
   generated by newsletter@****

The following text was generated during the delivery attempt:

------ pipe to |/usr/bin/php /home/mycpanelusername/public_html/myfile.php
      generated by newsletter@**** ------

Content-type: text/html
X-Powered-By: PHP/4.3.11

 

Any ideas?

Edited by flashisland
Guest helpbytes
Posted (edited)
I get an error, as I mentioned above, when I use that pipe address. This just doesn't make any sense.

 

Change your pipe to:

 

>|/usr/bin/php /home/mycpanelsusername/public_html/myfile.php > /dev/null

 

Thats all on one line. It redirects the output of php to nowhere. the problem now is that php is outputting a header to stdout which makes exim think there was an error in processing.

 

The -q inside the actual script with the php command should have stopped that, but that pipe above should cure you.

Edited by helpbytes
Posted (edited)

Nope, it still won't work! I'm getting really sick of this script by now! I still keep getting the same "A message that you sent could not be delivered to one or more of its recipients." error.

 

Edit: The script does however send me the testing email still.

Edited by flashisland
Guest helpbytes
Posted

the redirect doesn't work

 

This does though, at least for me it does:

 

>|/usr/bin/php -q /home/mycpanelsusername/public_html/myfile.php

Posted

Using this filter:

>|/usr/bin/php -q /home/mycpanelsusername/public_html/myfile.php

...should be the same as using this filter:

>|/home/mycpanelsusername/public_html/myfile.php

...with the shebang line in line 1 of the script:

>#!/usr/bin/php -q

If you use the first filter above, I'd recommend removing the shebang line from the script - it's redundant, and php is likely to output it as plain text when the script runs.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...