PHP Classes

Undelivered (bounce) Mails

Recommend this page to a friend!

      pop3ml  >  All threads  >  Undelivered (bounce) Mails  >  (Un) Subscribe thread alerts  
Subject:Undelivered (bounce) Mails
Summary:Processing undelivered mails
Date:2009-07-03 15:51:05
Update:2009-07-13 22:10:49

  1. Undelivered (bounce) Mails   Reply   Report abuse  
Picture of Ron Ron - 2009-07-03 15:51:05
Hi Giuseppe,

thanks for the great class!

Does the class handle undelivered (bounce) mails? It seems that the return-path is set to the listmail address. That way bounce mails would themselves be send to the mailing list, which could eventually end up in a vicious circle. Hope, I got that wrong.


  2. Re: Undelivered (bounce) Mails   Reply   Report abuse  
Picture of giuseppe lucarelli giuseppe lucarelli - 2009-07-04 07:15:18 - In reply to message 1 from Ron
hi ron
thank you very much for your post.
in this release there is not a bounce mail management, but in my running mailing lists bounced mails are dropped as unsubscribed senders (mailer-daemon, noreplay,..), but i know is trivial.
anyway i'm working hard at new release, where i've inserted bounce detection with owner notify, mail filter (procmail like), parent/children sublist,multi rcpt to... and correcting some bugs (thanks to gregor buchholz). a big problem for me is debugging all that stuff (i didn't figure out it's so complicated) and writing a patch script to update old release).

  3. Re: Undelivered (bounce) Mails   Reply   Report abuse  
Picture of Ron Ron - 2009-07-06 08:06:59 - In reply to message 2 from giuseppe lucarelli
Hi Guiseppe!
My bounce mails were send back to the mailing list, because I ran your class with the subscribersonly-option set to "no", since I needed one mailing-list to be accessible to the public. So, I'll eagerly wait for your new release with the bounce mail management.

For my purpose it was also necessary to turn off self-subscription by commenting the following lines in function setConfirmedAddress($address):

$query = 'update '.$this->mltable.' set sublist = \''.
trim($this->sublist).'\' where listname = \''.$this->listname.'\'';
if($command = @mysql_query($query,$this->dbconn)) {
echo "confirmed subscription [$address]\n";

It would be great to have an option to disallow self-subscription.

I also wanted senders who are not listed in allowsublist to get a message telling them that their mail was not transmitted. That's why I added these lines to function checkSender($address) at the end of if(is_array($this->allow)) {}

if($retval == 'deny' && !eregi("Mailer-Daemon", $address)){
$subject = "Mail to $this->listaddress was not posted";
$body = "some info";
mail($address, $subject, $body, null, '');

Finally, I received an error message with multiple mailing lists, so I had to change
stream_wrapper_register('pop3', 'pop3_stream');
in function init() to:

if(!in_array("pop3", stream_get_wrappers())){
stream_wrapper_register('pop3', 'pop3_stream');


  4. Re: Undelivered (bounce) Mails   Reply   Report abuse  
Picture of giuseppe lucarelli giuseppe lucarelli - 2009-07-07 13:22:03 - In reply to message 3 from Ron
Hi Ron.
For bounced email you can put an header value into 'mltable' 'headerchange' field, like:


to bounce emails to ml owner email, or:

to bounce emails to this address.
About disabling self-subscription i've enabled 'subscription moderation' in the new release, so every subscription request will be sent to moderator list, in case accepted. i hope you find this helpful.
i've also enabled notification for undelivered email, as you suggested in your post.
thanks for 'stream_wrapper_register' bug. i've been already told by Gregor.
If you are using my script for real, please change the field 'addresses' in the table 'queue' from tinytext to longtext and all the rows like:

if(!preg_match('/(^|\n)'.$address.'(\n|$)/',$this->sublist)) {

adding the `i' character to pattern, for case-insensitive sender address detection:


if you like to have a preview of new release, in a couple of days i'll be able to put a tarball at: ...
please feel free to send me any king of suggestion, bad/good comment,...

  5. Re: Undelivered (bounce) Mails   Reply   Report abuse  
Picture of Ron Ron - 2009-07-07 13:59:18 - In reply to message 4 from giuseppe lucarelli
Thanks for your information!

I tried including the return-path into the 'mltable' 'headerchange' before, but it doesn't work for me, unfortunately. I guess, this is because my provider only allows to set the return path via the mail(-freturn-path)-way. However, with the bounce management I wouldn't need it anyway.

I'll certainly try the new release.

Keep up the great effort!


  6. Re: Undelivered (bounce) Mails   Reply   Report abuse  
Picture of giuseppe lucarelli giuseppe lucarelli - 2009-07-13 08:27:20 - In reply to message 5 from Ron
Hi ron.
Thank you for encouragement. i've started a massive debug from scratch because i've made so many changes i'm sure there are plenty of bugs.
the last was inserting the excellent class 'Bouncehandler' to manage bounced email in more secure manner.
anyway i've updated the tarball at and i'll be very grateful if you could possibly have a look of code (only if you have a little time to spend for it) and tell me what you think of it.

  7. Re: Undelivered (bounce) Mails   Reply   Report abuse  
Picture of Ron Ron - 2009-07-13 22:10:49 - In reply to message 6 from giuseppe lucarelli
Hi Guiseppe,
I probably won't be able to make it within the next days. But I am planing to give it a try during the weekend.