PDA

View Full Version : vBouncer : Unsubscribe threads for members with bouncing emails


tamarian
05-31-2003, 10:00 PM
What vBouncer does
vBouncer will reduce your server load, bandwidth, and your forum admin in-box, by unsubscribing members who keep bouncing their emails back to your forum admin email, which may bomb your mail box if you have a busy forum with many members who subscribe to many threads, but their emails are either invalid, in box full, or have ISP problems.

Screen shots
None, this is a command line script, with some changes in functions.php

Who may want to use this?
1. Very busy sites, with thousands of notifications a day.
2. Your admin box gets too many bouncing emails
3. You use sendmail. I'm not sure how this works on other mail servers.

Caution
This may drive some of your members mad :) If their email bounces a lot, this script will unsubscribe them from their favourite threads. They will have to fix their email account, and then subscribe manually to each thread again... This may not be due to bad emails, just ISP side problems.

Use at your own risk. I'm sharing this since some indicated interest at vBulletin.com in this thread:
http://www.vbulletin.com/forum/showthread.php?threadid=71496
I'd be glad to help answer questions, but as with most hacks, it is your responsibility....

Installation
1. Create a unique email address on your server, dedicated to catch bouncing emails. Do not use adminemail, or any other existing email that you want to receive through a POP account. This email will be used only to catch bouncing emails.

Recommended name (makes for less editing): subscriber_notify

2. Edit functions.php

Find:
// work out the 'From' header
if ($from == '') {
$headers = "From: \"$bbtitle Mailer\" <$webmasteremail>\r\n" . $headers;
} else {
$headers = 'From: "' . iif($username, "$username @ $bbtitle", $from) . "\" <$from>\r\n" . $headers;
}

// actually send the email message
mail($toemail, $subject, $message, trim($headers));

Replace with:
// work out the 'From' header
if ($from == '') {
$from = $webmasteremail;

$headers = "From: \"$bbtitle\" <$webmasteremail>\r\n" . $headers;
} else {
$headers = 'From: "' . iif($username, "$username @ $bbtitle", $from) . "\" <$from>\r\n" . $headers;
}

// actually send the email message
mail($toemail, $subject, $message, trim($headers), "-f$from");


Find:

vbmail($touser['email'], $emailsubject, $emailmsg);


Replace with: replace subscriber_notify@example.com with your domain name)

$emailerusername = "New Reply Notification";
$emailer = "subscriber_notify@example.com"; // change this to your bouncer email account.
$emailerheader = "Reply-To: $emailer\nErrors-To: $emailer\n";
vbmail($touser['email'], $emailsubject, $emailmsg, $emailer, $emailerheader, $emailerusername);


3. Copy vBouncer.pl.txt to a directory on your server. vBouncer.pl.txt is attached below.

Rename it to vBouncer.pl by typing:

mv vBounver.pl.txt vBouncer.pl

Make it executable by typing:

chmod +x vBouncer.pl

4. Edit the configuation section of vBouncer.pl

#! /usr/bin/perl -w
#
# USAGE: vBouncer.pl -bounce : to unsubscribe threads from members with bouncing email
# vBouncer.pl : with no parameters to see (test) who will be unsubscribed
#
# When done, remember to reset the email file,
# cp /dev/null subscriber_notify (or whatever filename your bouncing email file is chosen)
#
# Copyright (c) 2003 Mad SCO Disease, released under GPL. Mad SCO Disease reserves the right
# to sue your butt, if you don't buy out their small time company. Check eBay for current bids.
#
# Details on Mad SCO Disease provided here: http://www.opensource.org/sco-vs-ibm.html
# For the proper way to eat sane cows, check here: http://www.lowcarb.ca

# Config:
my $bouncelimit = 25; # how much bounced emails are allowed, before taking actions
my $unsubscribe = 1; # unsubscribe member from all subscribed threads, 1=yes, 0=no
my $changedefault = 1; # change subscription default to no. 1=yes, 0=no
my $nobulletin = 0; # This is only for those who installed the newsletter bulletin hack
# change receive bulletin option to no. 1=yes, 0=no
my $changeusergroup = 0;# change user group to bounced group, 1=yes, 0=no
# THIS IS NOT RECOMMENDED USE WITH CAUTION
# IF AMINS AND/OR MODS BOUNCE EMAILS, IT WON'T CHECK
# IF you really want to use this option, you will need to uncomment the code
my $bouncedgroup = 2; # the usergroup id for bouncing members, be careful, this number
# must match the user group id you setup in the vb control panel (not yet implemented)

my $bouncefile = "/var/spool/mail/subscriber_notify";
# the path/to/bouncing emails file. "subscriber_notify is the email name, you need
# to change it to the email name you chose for bouncing emails.

my $db="database"; # mysql database name
my $db_host="localhost"; # mysql host
my $db_username="username"; # mysql username
my $db_password="password"; # mysql password


5. Once a week or so, you can run the scropt manually, or through a cron job. When done, you have to clear the email file, otherwise it will keep unsubscribing members whos emails no longer bounce.

To run the script in test mode, type:

./vBounver.pl

To run the script in bouncer mode, type:

./vBounver.pl -bouncer

To clear the mail box, use:
cat /dev/null > subscriber_notify

6. Optional bonus: If you have very long threads, you can queue emails until the server load is acceptable. Edit /etc/sendmail.cf

Find:
# load average at which we just queue messages
#O QueueLA=5

Change to:
# load average at which we just queue messages
O QueueLA=3

This basically means sendmail will not attempt to deliver the email if your server is at load average of 3 or greater, it will place it in the mail queue for later delivery. You can change this number to suit your needs.

Planned enhancments (will wait for vB 3.0)

1. Instead of unsubscribing members threads, suspend notification by making a copy of their subscriptions, and copying them back when emails no longer bounce.

2. Track bounce history through admin panel,. This is similar to the old eGroup bouncing history.

3. Automatically PM members re their bounced emails.

4. Offer an option to admin to disable email notification to bouncing members, but keep the subscription. Similar to vB 3.0's daily and weekly notification, but adding a "no emails" option. This is also planned to be a seperate hack. If someone already has access to vB3.0, feel free to use this idea :)


Attached file is dated June 1st, 2003

cirisme
06-01-2003, 08:38 PM
Nice. :D

Will have to give it a try. :)

colicab-d
06-01-2003, 08:41 PM
just so u know.. its agood idea to attach hacks in a txt or zip file so unlicensed users cant get a hold of them.. just thought id beat the mods too it lol soz

tamarian
06-01-2003, 09:11 PM
Today at 10:41 PM colicab-d said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=403085#post403085)
just so u know.. its agood idea to attach hacks in a txt or zip file so unlicensed users cant get a hold of them.. just thought id beat the mods too it lol soz


It is attached as a text file..... :)

tamarian
06-01-2003, 09:14 PM
What I like most about this script, is the copyright notice! I'm surprised no one remarked on it.... ;)

Erwin
06-02-2003, 04:18 AM
How very cool! I love this idea... shall look into this further when I get home...

Overgrow
06-02-2003, 03:39 PM
EXCELLENT! Thanks so much for the hack. I'm using a modified 2.2.9 and since the mail routines were changed going to 2.3.0, it did not install as described. I couldn't get the mail to bounce back to a new handle, so I'm just pulling it from the normal bounce pile.

Thanks again.. licks install... this ought to save me a few thousand emails a week.

tamarian
06-02-2003, 08:06 PM
Today at 05:39 PM Overgrow said this in Post #7 (https://vborg.vbsupport.ru/showthread.php?postid=403416#post403416)
I'm using a modified 2.2.9 and since the mail routines were changed going to 2.3.0, it did not install as described.

Here's how to do it for 2.2.9, only one line to change. I have not tested this, since both my server and test server both run 2.3, but it should work. From reading about the PHP mail parameter, it doesn't work sometimes with safe mode is on....

In functions.php, find:
mail($touser[email],$emailsubject,$emailmsg,"From: \"$bbtitle Mailer\" <$webmasteremail>");

Replace with:
$bouncemail = "subscriber_notify@example.com"; // change this to the new email account dedicated to bounced notification emails.
mail($touser[email],$emailsubject,$emailmsg,"From: \"$bbtitle Mailer\" <$webmasteremail>"," -f$bouncemail");

If anyone trys this one and it works :) , please let me know. I'll add it to the instructions.

Edit: Modified for an enhancement mentioned 3 posts below.

pgowder
06-03-2003, 07:59 PM
Yesterday at 05:06 PM tamarian said this in Post #8 (https://vborg.vbsupport.ru/showthread.php?postid=403543#post403543)
Here's how to do it for 2.2.9, only one line to change. I have not tested this, since both my server and test server both run 2.3, but it should work. From reading about the PHP mail parameter, it doesn't work sometimes with safe mode is on....

In functions.php, find:
mail($touser[email],$emailsubject,$emailmsg,"From: \"$bbtitle Mailer\" <$webmasteremail>");

Replace with:
$bouncemail = "subscriber_notify@example.com"; // change this to the new email account dedicated to bounced notification emails.
mail($touser[email],$emailsubject,$emailmsg,"From: \"$bbtitle Mailer\" <$bouncemail>"," -f$bouncemail");

If anyone trys this one and it works :) , please let me know. I'll add it to the instructions.

I'm trying that now, but before I could finish installing, I've noticed that all the emails are now coming to my Outlook???

pgowder
06-03-2003, 08:06 PM
Looks like that made it send all emails to that address and not just those that bounce.

tamarian
06-03-2003, 09:38 PM
Today at 09:59 PM pgowder said this in Post #9 (https://vborg.vbsupport.ru/showthread.php?postid=404031#post404031)
I'm trying that now, but before I could finish installing, I've noticed that all the emails are now coming to my Outlook???

I can only see this happening, if the members who successfully received an email notification decide to reply to that email, instead of posting on the forum.

In that case, yes, it will go to that address. I didn't consider this a problem, but I will edit my 2.2.9 code to avoid that. In that case is will go to the admin email.

If it arrives to outlook express, you might have missed some steps. I any of the steps have been missed, or not folowed exactly as written, please let me know which ones.

Do you use sendmail?

Did you create a new email account (subscriber_notify)?

To receive it through Oulook or any POP client , you need to set up your email client for that email address. For this vBouncer to work, you should not set it up as a POP client for the vBouncer dedicated email account, just leave it on the server to collect bounced emails.

If you did not set a POP client, then it is possible you are getting the emails forwarded to the "catch-all" account, if the email was misspelled.

Hope this helps

CJi
07-04-2003, 04:11 PM
Works marvellously! Clicks install!

CJi
07-05-2003, 04:07 PM
I have noticed that regardless of whether -bouncer was specified or not, it ran in test mode. To correct this, make the following changes:

line 65: change: $bouncemode =0; to: $bouncemode = 1;

It seems in some versions of perl (or indeed all?) it's similar to php - setting a variable with a 0 (zero) in effect wipes that variable, changing it to a 1 sets it so that the if($bouncemode) works correctly.

tamarian
07-05-2003, 04:17 PM
Today at 06:07 PM CJi said this in Post #13 (https://vborg.vbsupport.ru/showthread.php?postid=415500#post415500)
I have noticed that regardless of whether -bouncer was specified or not, it ran in test mode. To correct this, make the following changes:

line 65: change: $bouncemode =0; to: $bouncemode = 1;

It seems in some versions of perl (or indeed all?) it's similar to php - setting a variable with a 0 (zero) in effect wipes that variable, changing it to a 1 sets it so that the if($bouncemode) works correctly.


It's more like lack of coffee :)

File updated, thanks for the correction.

CJi
07-05-2003, 04:36 PM
Pleasure! I'm just glad it was something that simple ;)

CJi
07-15-2003, 10:28 AM
<a href="http://www.ukairsoft.net/bounce.php" target="_blank">http://www.ukairsoft.net/bounce.php</a>

I've automated the process so users can keep abreast of the problem as well as changed the system slightly. I'll be happy to share the code if anyone is interested.

Lesane
07-19-2003, 02:43 PM
^that would be cool CJI.

tamarian, i get the following error when i execute vbouncer.pl:

malformed header from script. Bad header=Running in test mode. No actio: /home/wildvibe/public_html/cgi-bin/vbouncer.pl

tamarian
07-19-2003, 02:56 PM
Today at 04:43 PM Lesane said this in Post #17 (https://vborg.vbsupport.ru/showthread.php?postid=418960#post418960)
^that would be cool CJI.

tamarian, i get the following error when i execute vbouncer.pl:

malformed header from script. Bad header=Running in test mode. No actio: /home/wildvibe/public_html/cgi-bin/vbouncer.pl


Are you running it from a browser? If so, try running it from the command line. Also, take out of public_html directory, to a directory above the html document root, for security reasons.

CJi
07-24-2003, 10:35 PM
Please find attached the (slightly) modified bouncer.pl code (basically added tables support and removed reporting of the userid as it doesn't mean an awful lot to my users.)

Create 2 shell scripts (bounce-list.sh and bounce-do.sh or similar, and make sure they are executable by you, the owner and are in the same group as your mail bounce file. (chmod 700 should suffice.)

bounce-list.sh:

#!/bin/sh
/root/./bouncer.pl -test > /home/virtual/site1/fst/var/www/html/output.html
A=`date "+%H:%M"`
T=`date "+%d/%m/%Y"`
echo "<br><br>Last Updated: $A on $T" >> /home/virtual/site1/fst/var/www/html/output.html


Note: -test is required to stop perl moaning about an empty variable check, or something. Replace /home/virtual[yadeya]/output.html with the file you would like to dump the results in. Then you can use php to include this file into your site template.

bouncer.sh:
As above, but replace -test with -bouncer.

These 2 scripts can then be placed in a crontab as required. I run mine every 8 hours or so in list mode, and manually run the bouncer when I can remember/be bothered.

Original code author: If you do not wish this code to be published, please email me and I will remove it. Just trying to make a great piece of software just that little bit better. :)

tamarian
07-24-2003, 11:17 PM
Today at 12:35 AM CJi said this in Post #19 (https://vborg.vbsupport.ru/showthread.php?postid=420384#post420384)

Original code author: If you do not wish this code to be published, please email me and I will remove it. Just trying to make a great piece of software just that little bit better. :)

I don't mind a bit, all contributions and suggestions are welcome.

tamarian
08-10-2003, 08:41 PM
I got emailed a question, and I'm answering here since the member has disabled the reply/email option and provided an email that bounces :)

I was wondering if the current verison of this hack would allow giveyou the option to disable or enable notification of emails pertaining to subscribed threads BUT will still continue to update you on subscribed threads only in the cp when email notification is disabled? If this is not upported by your hack, please let me know what hack can do this or of my idea is original. Please reply to my email at

Answer: This is not possible for vB2, as the option itself (subscribe without email notification) is not available in vB.

However, for vB3, it's easy, and I plan to do it for the vB3 version, when vB3 hacks are allowed here when vB3 RC is released.

mixylplik3
10-13-2003, 02:39 PM
This is great. I eagerly await a vB3 version. :)

sabret00the
10-24-2003, 06:33 PM
what a great hack, suprised i never saw it earlier

kontrabass
02-07-2004, 11:46 PM
Major bump for VB3! Please ;)

tamarian
02-07-2004, 11:50 PM
Major bump for VB3! Please ;)

LOL, I'm typing the instructions for vB3 right now

tamarian
02-08-2004, 12:40 AM
vB3 version of vBouncer is posted here:

https://vborg.vbsupport.ru/showthread.php?t=61303

tamarian
06-21-2005, 07:12 PM
There's a new PHP version of vBouncer with Admin panel access for vB 3.5 check it out:

https://vborg.vbsupport.ru/showthread.php?s=&threadid=83486