Select by search string

Post Reply
rafaelfpviana
Junior Member
Posts: 14
Joined: 12 Dec 2006, 12:18
Location: Brazil

Select by search string

Post by rafaelfpviana »

I was tired of checking my e-mail and reciving all those "Warning: Message XXXX..." or " Undelivered Mail Returned to Sender" or even "Mail delivery failed: returning messag.." and I usally get many of these when I send out news letter.

So instead of downloading them and removing it on my e-mail program I decided to use CMM to do that.

I used to check the "check all" option and them "Delete Selected" but sometimes that would delete important e-mails.

So I wrote a javascript snippet to check only those messages that had a certain string on the subject of the and then check it.

This is good because now I can delete the e-mails before I download them. Take a look below, you can copy and paste it on addon_cmm.cgi:

on cmm: v1.07 go to line 534 where it sais:

Code: Select all

print "	}\n";
and add this bellow it:

Code: Select all

print "}\n";
print "RegExp.escape = function(text) {\n";
print "		if (!arguments.callee.sRE) {\n";
print "			var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\\\'];\n";
print "				arguments.callee.sRE = new RegExp('(\\\\' + specials.join('|\\\\') + ')', 'g');\n";
print "			}\n";
print "	 	return text.replace(arguments.callee.sRE, '\\\\\$1');\n";
print "}\n";
print "function selectSearch(){\n";
print "		var reg = new RegExp(RegExp.escape(document.listmail.searchFor.value), 'i');\n";
print "		for (var x = 0; x < document.listmail.elements.length; x++) {\n";
print "			if (document.listmail.elements[x].type == 'checkbox' && document.listmail.elements[x].name != 'checkall') {\n";
print "				var trPai = document.listmail.elements[x].parentNode.parentNode;\n";
print "				var allTds = trPai.getElementsByTagName('TD');\n";
print "				var theLink = allTds[2].getElementsByTagName('A');\n";
print "				if( reg.test(theLink[0].innerHTML) ){\n";
print "					document.listmail.elements[x].checked = true;\n";
print "				}\n";
print "			}\n";
print "		}\n";
now go to line 633, there should be this:

Code: Select all

print "<tr class='$class'><td> </td><td align='center'><input type='checkbox' name='checkall' OnClick='checkme()'>
All</td><td colspan='4'><input type='hidden' name='total' value='$total'><input type='submit' value='Delete Selected'></td></tr>\n";
now add this right bellow it:

Code: Select all

print "<tr class='$class'><td align='right'> </td><td> </td><td colspan='4'><input type='text' name='searchFor' /> - <input type='button' value='Select by search' onclick='javascript:selectSearch();' /></td></tr>\n";
Now save and replace the addon_cmm.cgi file on the server with this one that you've modified.

Chirpy, I hope you add this on the next version :D
chirpy
Moderator
Posts: 3537
Joined: 09 Dec 2006, 18:13

Post by chirpy »

Thanks, I'll put it on the development list :)
ovisopa
Junior Member
Posts: 1
Joined: 27 Jan 2010, 16:26

Post by ovisopa »

can somebody update the lines we should edit to use this addon ? it will be great because I have a domain with thousants email mailboxes which are full of ***SPAM*** and already received messages cand be deleted using filters in cPanel, this addon will be great.

Thank you.
chirpy
Moderator
Posts: 3537
Joined: 09 Dec 2006, 18:13

Post by chirpy »

The option was included in cmm some years ago:
http://blog.configserver.com/index.php?itemid=282
Post Reply