Thread: [Postfixadmin-devel] Request help/comment on Feature Requests-2813224 : End user customization of h
Brought to you by:
christian_boltz,
gingerdog
From: Tanstaafl <tan...@li...> - 2011-12-15 13:25:21
|
Hi guys, I'd appreciate some comments/replies on this Feature Request for a documented way to easily add new from/mailfrom strings that will cause the vacation message to NOT be sent... I have seen numerous vacation messages sent that should NOT be sent (one example is documented on the FR)... https://sourceforge.net/tracker/?func=detail&atid=937967&aid=2813224&group_id=191583 Thanks, Charles |
From: Christian B. <pos...@cb...> - 2011-12-15 20:27:22
|
Hello, Am Donnerstag, 15. Dezember 2011 schrieb Tanstaafl: > I'd appreciate some comments/replies on this Feature Request for a > documented way to easily add new from/mailfrom strings that will cause > the vacation message to NOT be sent... > > I have seen numerous vacation messages sent that should NOT be sent > (one example is documented on the FR)... > > https://sourceforge.net/tracker/?func=detail&atid=937967&aid=2813224&g > roup_id=191583 Have a look at vacation.pl around line 558 to 569. There are lines like (broken into multiple lines for better readability) elsif (/^List\-(Id|Post|Unsubscribe):/i) { $logger->debug("List-$1: found; exiting"); exit (0); } You can add similar lines there, for example elsif (/^autoresponders-are:\s+evil/i) { $logger->debug("autoresponders-are: evil found; exiting"); exit (0); } would not respond to mails which have this header: Autoresponders-are: evil It shouldn't be too hard to make that a config option with an array or hash of regular expressions + corresponding log message, and I'll happily accept a patch implementing that. OTOH, I'm not sure if it is a good idea to make it configureable in the web interface. It might sound like a good idea at the first look, but IMHO people who can write proper regular expressions are the same people who prefer a config file ;-) - and everybody else could cause some breakage by wrong regular expressions. Regards, Christian Boltz -- Sieh an, ein Dichter und Denker, obwohl er sicherlich nicht mehr ganz dicht ist und auch nicht mehr oft denkt, sonst wäre er ja nicht bei uns gelandet ;D [Alex Klein in suse-linux] |
From: Robert S. <ro...@sc...> - 2011-12-15 21:35:48
|
Am 15.12.2011 21:27, schrieb Christian Boltz: > Hello, > > Am Donnerstag, 15. Dezember 2011 schrieb Tanstaafl: >> I'd appreciate some comments/replies on this Feature Request for a >> documented way to easily add new from/mailfrom strings that will cause >> the vacation message to NOT be sent... >> >> I have seen numerous vacation messages sent that should NOT be sent >> (one example is documented on the FR)... >> >> https://sourceforge.net/tracker/?func=detail&atid=937967&aid=2813224&g >> roup_id=191583 > > Have a look at vacation.pl around line 558 to 569. There are lines like > (broken into multiple lines for better readability) > > elsif (/^List\-(Id|Post|Unsubscribe):/i) { > $logger->debug("List-$1: found; exiting"); > exit (0); > } > > You can add similar lines there, for example > > elsif (/^autoresponders-are:\s+evil/i) { > $logger->debug("autoresponders-are: evil found; exiting"); > exit (0); > } > > would not respond to mails which have this header: > Autoresponders-are: evil > > It shouldn't be too hard to make that a config option with an array or > hash of regular expressions + corresponding log message, and I'll > happily accept a patch implementing that. > > OTOH, I'm not sure if it is a good idea to make it configureable in the > web interface. It might sound like a good idea at the first look, but > IMHO people who can write proper regular expressions are the same people > who prefer a config file ;-) - and everybody else could cause some > breakage by wrong regular expressions. > > > Regards, > > Christian Boltz as note, it might be a better alternative to use sieve ,if possible, to prefilter before vaccation for sure ,a complete other solution -- Best Regards MfG Robert Schetterer Germany/Munich/Bavaria |
From: Tanstaafl <tan...@li...> - 2011-12-19 18:11:11
|
On 2011-12-15 3:27 PM, Christian Boltz <pos...@cb...> wrote: > Hello, > > Am Donnerstag, 15. Dezember 2011 schrieb Tanstaafl: >> I'd appreciate some comments/replies on this Feature Request for a >> documented way to easily add new from/mailfrom strings that will cause >> the vacation message to NOT be sent... >> >> I have seen numerous vacation messages sent that should NOT be sent >> (one example is documented on the FR)... >> >> https://sourceforge.net/tracker/?func=detail&atid=937967&aid=2813224&g >> roup_id=191583 > > Have a look at vacation.pl around line 558 to 569. There are lines like > (broken into multiple lines for better readability) > > elsif (/^List\-(Id|Post|Unsubscribe):/i) { > $logger->debug("List-$1: found; exiting"); > exit (0); > } > > You can add similar lines there, for example > > elsif (/^autoresponders-are:\s+evil/i) { > $logger->debug("autoresponders-are: evil found; exiting"); > exit (0); > } > > would not respond to mails which have this header: > Autoresponders-are: evil Thanks Christian, but I have tried this about a year ago, but never could get it to work (vacation messages would still go out. > It shouldn't be too hard to make that a config option with an array or > hash of regular expressions + corresponding log message, and I'll > happily accept a patch implementing that. Wish I could, but that would be way beyond my pay grade. ;) > OTOH, I'm not sure if it is a good idea to make it configureable in the > web interface. It might sound like a good idea at the first look, but > IMHO people who can write proper regular expressions are the same people > who prefer a config file ;-) - and everybody else could cause some > breakage by wrong regular expressions. I agree regexes are easily messed up, which is why I'd like this to be in the GUI - to avoid mistakes. I'd like to simply be able to add a text string that would be added to a list of 'generic headers' (anything in a From or Envelope header) to not respond to - so if I add the string 'Autoresponders-are: evil' (minus the quotes), then the GUI would set up the regex properly. |
From: Sonam P. <s_p...@ru...> - 2011-12-16 06:04:08
|
Hi guys, I have started to add features to creates email id by uploading CSV file (bulk). I am just wondering how much MB would be suitable for upload as it involves operations: validation, checking of previous email id, calculating the quotas and password. Although, the upload size can be configured from php.ini file but still to perform above operations as especially in my case I have to keep in mind the CPU speed and bandwidth. Any other operations that may be required. I would appreciate for recommendations / comments to move forward. Thanks Sonam -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
From: David G. <da...@co...> - 2011-12-16 09:11:59
|
On 16 Dec 2011, at 05:36, Sonam Penjor wrote: > Hi guys, > > I have started to add features to creates email id by uploading CSV file > (bulk). > I am just wondering how much MB would be suitable for upload as it > involves operations: validation, checking of previous email id, > calculating the quotas and password. Is this MB in terms of memory usage within PHP while it processes the upload, or MB in terms of file size for how large your CSV may be? > Although, the upload size can be configured from php.ini file but still > to perform above operations as especially in my case I have to keep in > mind the CPU speed and bandwidth. Any other operations that may be > required. > I can't see how even a 20Mb CSV file would cause any significant problems on a reasonably specified server. Opening the CSV file and reading it one line at a time using fgetcsv() and then presumably doing around 3-5 database queries (is it there? update? insert? delete?) should really not be a problem. I think all recent versions of PHP default to a 128mb memory limit should should be fine. I have a feeling the file_upload_size thing defaults to about 2mb, which may be too small. David. |
From: Christian B. <pos...@cb...> - 2011-12-18 17:46:12
|
Hello, Am Freitag, 16. Dezember 2011 schrieb Sonam Penjor: > I have started to add features to creates email id by uploading CSV > file (bulk). > I am just wondering how much MB would be suitable for upload as it > involves operations: validation, checking of previous email id, > calculating the quotas and password. > Although, the upload size can be configured from php.ini file but > still to perform above operations as especially in my case I have to > keep in mind the CPU speed and bandwidth. Any other operations that > may be required. As David already mentioned, the php file_upload_size might need some tuning. (OTOH, one mailbox means somewhat between 50 and 100 byte in CSV, so you'll at least have 2000 mailboxes in 1 MB CSV file. That's a lot already ;-) Another setting that might hit you is the max_execution_time. (You can work around it by doing a self-redirect after creating 50 or 100 mailboxes with ?csvfile=uploaded_file.csv&continue_with_line=51) You can tune both settings in your PHP configuration, so this shouldn't be a real problem. You might also want to consider the command line client instead of the web interface for mass creation of mailboxes. > I would appreciate for recommendations / comments to move forward. Most important: Please use the MailboxHandler class (see below for details). create-mailbox.php and edit-mailbox.php are dead code (in maintenance mode) and will be deleted sooner or later. Please don't add new features to one of those files. Another important thing is to base your changes on SVN trunk. At the moment, using MailboxHandler means something like: $handler = new MailboxHandler($address); if (!MailboxHandler->add($password, $name, $quota, $active, $mail)) { die ('creating the mailbox failed - ' . $handler->errormsg); } $address is the username / mail address $password should be obvious ;-) $name is the realname / comment / whatever $quota means quota in MB $active is usually just true $mail means sending the welcome mail and also should be true See scripts/shells/mailbox.php -> AddTask -> __handle() (part of the command line client) for a working implementation that uses this class. Whenever I have some time [1], I'll update MailboxHandler to use the function names etc. I'm already using in DomainHandler and AdminHandler (see edit.php for working implementation). This means you'll need some small changes in your script on how you call MailboxHandler, but that will be quite easy. Regards, Christian Boltz [1] If you want to update MailboxHandler to be based on PFAHandler, of course nobody will stop you ;-) -- Intel kauft McAfee. [...] Der Synergieeffekt ist offensichtlich. McAfee macht Computer so langsam, dass man eine neue Intel-CPU braucht. Ähnliche Synergieeffekte gibt es zwischen [...] Computerspielen und Grafikkartenbedarf und zwischen Webforen und Tischkantenbedarf. [http://blog.fefe.de/?ts=b2935cd1] |
From: Sonam P. <s_p...@ru...> - 2011-12-28 11:42:14
|
Hello, I have completed the validation of the CSV file for bulk email ID creation. I have brown down my works into two parts (for my reference). PART I - upload the csv file and validate the contents (line by line), display the status. PART II - will create the mail box. So far I completed the PART - I: 1. Uploaded the csv file and validated whether uploaded file is in csv format or other. 2. Validated the username (check whether space exist in between) 2. Check for the existence of username 3. Considered as an error if sl no 1 and 2 exist. 4. Total mail box ready for creation (number of correct entries without the entry row of sl 1 and sl 2) 5. Displayed the status After displaying the status I am requesting admin whether to create (process) or to cancel. Now, to process, there will be post method again where the uploaded values or contents from PART I will no longer exist. I am just wondering whether I should create temporary table or file or use SESSION to store all the data collected from PART I for the PART II purposes. I would appreciate for your comments and advice Thank you Sonam Penjor -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
From: Rudi F. <rud...@go...> - 2011-12-28 12:23:05
|
Can't you add the csv as hidden form field(s)? Am 28.12.2011 12:42, schrieb Sonam Penjor: > Hello, > > I have completed the validation of the CSV file for bulk email ID > creation. I have brown down my works into two parts (for my reference). > PART I - upload the csv file and validate the contents (line by line), > display the status. PART II - will create the mail box. > > So far I completed the PART - I: > 1. Uploaded the csv file and validated whether uploaded file is in csv > format or other. > 2. Validated the username (check whether space exist in between) > 2. Check for the existence of username > 3. Considered as an error if sl no 1 and 2 exist. > 4. Total mail box ready for creation (number of correct entries without > the entry row of sl 1 and sl 2) > 5. Displayed the status > > After displaying the status I am requesting admin whether to create > (process) or to cancel. > > Now, to process, there will be post method again where the uploaded > values or contents from PART I will no longer exist. I am just wondering > whether I should create temporary table or file or use SESSION to store > all the data collected from PART I for the PART II purposes. > > I would appreciate for your comments and advice > > Thank you > > Sonam Penjor > > > > |
From: Christian B. <pos...@cb...> - 2011-12-28 19:17:21
|
Hello, Am Mittwoch, 28. Dezember 2011 schrieb Rudi Floren: > Can't you add the csv as hidden form field(s)? Short answer: No(t really). Longer answer: That would mean it _must_ be validated again in the next step, because an attacker could use a manipulated form. I know we are talking about authentificated admins here, but still. (And there are lots of setups where you can't trust every admin - for example, I give my customers admin access for their domains. I'd guess none of them knows how to manipulate a form, but if someone finds it out (firebug isn't that hard to use), I don't want to be f***ed off ;-) Not to mention that a hidden form field would mean to send lots of useless bytes around the world twice ;-) > Am 28.12.2011 12:42, schrieb Sonam Penjor: > > I have completed the validation of the CSV file for bulk email ID > > creation. I have brown down my works into two parts (for my > > reference). PART I - upload the csv file and validate the > > contents (line by line), display the status. PART II - will > > create the mail box. > > > > So far I completed the PART - I: > > 1. Uploaded the csv file and validated whether uploaded file is in > > csv format or other. > > 2. Validated the username (check whether space exist in between) > > 2. Check for the existence of username > > 3. Considered as an error if sl no 1 and 2 exist. How does your error handling look like? Abort if at least one problem is found? Or just skip the invalid and existing mailboxes? > > 4. Total mail box ready for creation (number of correct entries > > without the entry row of sl 1 and sl 2) > > 5. Displayed the status Does this mean you'll display a page with sections like - The following mailboxes already exist and will be skipped: - The following usernames are invalid and will be skipped: - The following mailboxes will be created: > > After displaying the status I am requesting admin whether to > > create (process) or to cancel. > > > > Now, to process, there will be post method again where the > > uploaded values or contents from PART I will no longer exist. I > > am just wondering whether I should create temporary table or file > > or use SESSION to store all the data collected from PART I for > > the PART II purposes. I would use the session - it is easy to use, and we get an automatic cleanup by PHP (at logout or session timeout) for free. In other words: handling a temporary table or file causes lots of additional work without any benefit. If you implement it in a nice way (I'd say: after creating a mailbox, delete it from the list in the session), the code can even continue with the remaining mailboxes after it was stopped (because of PHP max_execution_time etc.) Combined with some AJAX, you could exit the script yourself some seconds before max_execution_time and call it again. This would even allow you to draw a nice progress bar ;-) (That said: please use lightweight code and don't introduce a big JS framework just for doing this - otherwise I'll recommend to just use self-redirects in an <iframe> *g* Hmm, thinking about it, why not use <iframe> self-redirects from the beginning?) Oh, BTW: If you send your code early, you'll get an early review and changes (if needed) will be easier. Regards, Christian Boltz -- |#| Die drei wichtigsten Tugenden eines Programmierers: |#| Faulheit, Ungeduld und Selbstüberschätzung |
From: Christian B. <pos...@cb...> - 2011-12-29 00:48:12
|
Hello, Am Mittwoch, 28. Dezember 2011 schrieben Sie: > Whats about saving the validated csv To a tmp dir in fs. In the next > step the csv Form the Fa is processed. That would work (given we have a writeable tempdir, find a non- conflicting filename, ...) In other words: storing everything in the session is easier ;-) _if_ the session explodes one day, we can change it - but until then, we can use the easy solution. > For more security wie can add > some security tokens to forms. Well, a token might make sense - not security wise, but to avoid conflicts if a user opens two tabs and uses the bulk creation in both tabs in parallel. (Users sometimes have creative ideas...) Especially if we support resuming after max_execution_time timeouts etc. slightly OT: A token might really make sense in the login form, and we should also include the session id as hidden field to verify that the browser accepts cookies. Regards, Christian Boltz -- Ich habe da eine Theorie: Betriebssysteme melden Fehler und wollen, dass sie behoben werden. Bei Systemen wie Windows 9x sind die Fehler wesentlicher Bestandteil und kein Grund, sich Sorgen zu machen. [Steffen Lauterkorn in suse-linux] |
From: Sonam P. <s_p...@ru...> - 2011-12-29 09:02:30
|
Hello, How about using set_time_limit (0) In order to execute the CSV file... sonam On 12/29/2011 6:48 AM, Christian Boltz wrote: > Hello, > > Am Mittwoch, 28. Dezember 2011 schrieben Sie: >> Whats about saving the validated csv To a tmp dir in fs. In the next >> step the csv Form the Fa is processed. > That would work (given we have a writeable tempdir, find a non- > conflicting filename, ...) > > In other words: storing everything in the session is easier ;-) > > _if_ the session explodes one day, we can change it - but until then, we > can use the easy solution. > >> For more security wie can add >> some security tokens to forms. > Well, a token might make sense - not security wise, but to avoid > conflicts if a user opens two tabs and uses the bulk creation in both > tabs in parallel. (Users sometimes have creative ideas...) > Especially if we support resuming after max_execution_time timeouts etc. > > > slightly OT: A token might really make sense in the login form, and we > should also include the session id as hidden field to verify that the > browser accepts cookies. > > > Regards, > > Christian Boltz -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
From: Christian B. <pos...@cb...> - 2011-12-29 12:29:41
|
Hello, Am Donnerstag, 29. Dezember 2011 schrieb Sonam Penjor: > How about using set_time_limit (0) > > In order to execute the CSV file... You can try it, but I wouldn't be surprised if suhosin stops you from doing that ;-) Regards, Christian Boltz -- > > [OOo splash] kroete should turn their eyes during load ;-) > It should roll with his eyes if user is doing something completely > stupid. ...like touching the mouse, or do you know even better heuristics? [> Robert Schiele and Hans-Peter Jansen] |
From: Sonam P. <s_p...@ru...> - 2012-01-11 12:17:36
|
Hello, Creation of bulk email address is almost complete. Procedure of email creation are the following: 1. Uploading and reading CSV file as usual 2. Printing the status of CSV file 3. creating the email address by taking care of maximum_execution time Regrading number three: I self-redirect after creating certain mailboxes with ?csvfile=uploaded_file.csv&continue_with_line=51 before 5 seconds of maximum execution time as recommended by Mr. Christian Boltz (Thank You very much). For this simple re-direction I am using simple header php function, I don't know whether this method is correct??. Your help or recommendation would be helpful. As I am coding directly base on SVN trunk, I using the MailBoxHandler class. The following piece of code is used to create email address using the separate class: $i = $this -> continue_with_line; $bulkMail = $_SESSION["user"]; foreach ($bulkMail["user"] as $mail => $username) { if(is_array($username)) { $MailHandler = new MailboxHandler($usernam[$i]["username"]); if (!$MailHandler->add($usernam[$i]["password"], $name, $quota, $active, $mail)) { die ('creating the mailbox failed - ' . $handler->errormsg); } unset($_SESSION["user"][$i]); $i++; } } As you can notice from the above piece of code that I am creating multiple instances / constructor ( $MailHandler = new MailboxHandler($usernam[$i]["username"]) within the loop, Do I need to call destructor method after creating every mail box (If so then need to create destructor function in the MailboxHandler class) or leave it as it is or other suggestions. I would appreciate if you could provide recommendations or suggestions or advice to complete the above task. Thank You Sonam Penjor -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |
From: Christian B. <pos...@cb...> - 2012-01-11 22:19:49
|
Hello, Am Mittwoch, 11. Januar 2012 schrieb Sonam Penjor: > Creation of bulk email address is almost complete. Procedure of email > creation are the following: > > 1. Uploading and reading CSV file as usual > 2. Printing the status of CSV file > 3. creating the email address by taking care of maximum_execution time > > Regrading number three: > > I self-redirect after creating certain mailboxes with > ?csvfile=uploaded_file.csv&continue_with_line=51 I'd store the filename in the session instead of passing it around in the redirect. Besides that, it looks good. > before 5 seconds of > maximum execution time as recommended by Mr. Christian Boltz (Thank > You very much). For this simple re-direction I am using simple header > php function, I don't know whether this method is correct??. Your > help or recommendation would be helpful. Yes, header ("Location: [...]") is correct. > As I am coding directly base on SVN trunk, I using the MailBoxHandler > class. The following piece of code is used to create email address > using the separate class: ... > As you can notice from the above piece of code that I am creating > multiple instances / constructor ( $MailHandler = new > MailboxHandler($usernam[$i]["username"]) within the loop, Do I need to > call destructor method after creating every mail box (If so then need > to create destructor function in the MailboxHandler class) or leave > it as it is or other suggestions. You can leave it as is - PHP should automatically destruct the "old" MailboxHandler instance when you overwrite the $MailHandler variable with a new MailboxHandler instance. > I would appreciate if you could provide recommendations or suggestions > or advice to complete the above task. Everything looks good to me :-) and I'm looking forward to see your patch ;-) Regards, Christian Boltz -- >cat `rpm -qpil *.rpm` > packtete.txt *KREISCH* Erst 7. Januar und schon ist der "Useless use of cat"-Award 2004 vergeben. [> Markus Wunder und David Haller in suse-linux] |
From: Tanstaafl <tan...@li...> - 2012-02-19 20:19:16
|
On 2011-12-15 3:27 PM, Christian Boltz <pos...@cb...> wrote: >> I'd appreciate some comments/replies on this Feature Request for a >> documented way to easily add new from/mailfrom strings that will cause >> the vacation message to NOT be sent... >> >> I have seen numerous vacation messages sent that should NOT be sent > Have a look at vacation.pl around line 558 to 569. There are lines like > (broken into multiple lines for better readability) > > elsif (/^List\-(Id|Post|Unsubscribe):/i) { > $logger->debug("List-$1: found; exiting"); > exit (0); > } > > You can add similar lines there, for example > > elsif (/^autoresponders-are:\s+evil/i) { > $logger->debug("autoresponders-are: evil found; exiting"); > exit (0); > } > > would not respond to mails which have this header: > Autoresponders-are: evil Ok, one problem is, I don't usually get these emails, others do, so all I have are the log entries, not the full headers - yeah, I could ask the user to forward it to me or go look at it, but I'd like to be able to do this simply from the log entry, and also not provide a full header match, just a 'contains' match, see below... Here is another example of one I just saw go out (was watching the logs for something else): Feb 19 15:03:25 myhost postfix-25/smtpd[12575]: CCD158B3D5B: client=sv4-mta-52b.emailfiltering.com[208.87.137.233] Feb 19 15:03:26 myhost postfix/cleanup[12580]: CCD158B3D5B: message-id=<175...@el...d> Feb 19 15:03:26 myhost postfix/qmgr[11885]: CCD158B3D5B: from=<m-g...@bo...>, size=6660, nrcpt=2 (queue active) Feb 19 15:03:26 myhost postfix/virtual[12581]: CCD158B3D5B: to=<val...@me...>, relay=virtual, delay=0.38, delays=0.37/0/0/0.01, dsn=2.0.0, status=sent (delivered to maildir) Feb 19 15:03:26 myhost postfix-25/smtpd[12575]: disconnect from sv4-mta-52b.emailfiltering.com[208.87.137.233] Feb 19 15:03:26 myhost postfix-25/smtpd[12575]: connect from myhost.media-brokers.com[127.0.0.1] Feb 19 15:03:26 myhost postfix-25/smtpd[12575]: 9B082973CC9: client=myhost.media-brokers.com[127.0.0.1] Feb 19 15:03:26 myhost postfix/cleanup[12580]: 9B082973CC9: message-id=<201...@me...> Feb 19 15:03:26 myhost postfix/qmgr[11885]: 9B082973CC9: from=<val...@me...>, size=1133, nrcpt=1 (queue active) Feb 19 15:03:26 myhost postfix-25/smtpd[12575]: disconnect from myhost.media-brokers.com[127.0.0.1] Feb 19 15:03:26 myhost postfix/pipe[12591]: CCD158B3D5B: to=<validuser#med...@au...>, orig_to=<val...@me...>, relay=vacation, delay=0.92, delays=0.37/0.03/0/0.52, dsn=2.0.0, status=sent (delivered via vacation service) Feb 19 15:03:26 myhost postfix/qmgr[11885]: CCD158B3D5B: removed Feb 19 15:03:27 myhost postfix/qmgr[11885]: 9B082973CC9: removed Feb 19 15:03:27 myhost postfix/smtp[12594]: 9B082973CC9: to=<m-g...@bo...>, relay=post52.us.emailfiltering.com[208.87.137.137]:25, delay=1.2, delays=0.05/0.01/0.84/0.34, dsn=2.0.0, status=sent (250 accepted (1186764686)) What I would like is a simple way to add additional lines to vacation.pl, that would - ie, in this case - not respond to anything that had 'linkedin.com' *anywhere* (ie, a *contains* filter, not requiring an exact match) in the header or mailfrom. Or, maybe instead of linkedin.com, just anything with 'bounce' anywhere in the header or mailfrom (this is only the vacation responder, so I'm ok with not replying to some end-case message that maybe should have gotten replied to, if it stops all of these that should not get replied to)... Can you help with that constructing a line item for that? Then I could simply clone that one and change the string. Incidentally, the main reason I'm asking for help with this is testing it is hard, since it's not like we get these all the time, and nothing I've tried so far has worked (blocked these). But regardless, if I can get one working example, that would be awesome. Thanks Christian (or anyone else willing to help)! Charles |
From: Tanstaafl <tan...@li...> - 2012-02-21 11:06:46
|
On 2012-02-19 3:19 PM, Tanstaafl <tan...@li...> wrote: > Here is another example of one I just saw go out (was watching the logs > for something else): This is the line that I want to test for: > Feb 19 15:03:26 myhost postfix/qmgr[11885]: CCD158B3D5B: > from=<m-g...@bo...>, > size=6660, nrcpt=2 (queue active) Seeing as it contains a from= (this is the mail-from, not just some random from header, right?), I have tried the following, which doesn't seem to work: elsif (/^from:\s*(.*)\n$/i) { $logger->debug("linkedin.com found; exiting"); exit (0); } I need to know what expression to use for "from:\s*(.*)\n$/i)" to make this work so that if the from contains the string 'linkedin.com' anywhere, it will exit (0)... If I can get just one working example, then I can add a new line whenever I see one like this that I don't want to respond to. Appreciate any help anyone can provide... |
From: David G. <da...@co...> - 2012-02-21 11:50:19
|
On 21 Feb 2012, at 11:06, Tanstaafl wrote: > On 2012-02-19 3:19 PM, Tanstaafl <tan...@li...> wrote: >> Here is another example of one I just saw go out (was watching the logs >> for something else): > > This is the line that I want to test for: > >> Feb 19 15:03:26 myhost postfix/qmgr[11885]: CCD158B3D5B: >> from=<m-g...@bo...>, >> size=6660, nrcpt=2 (queue active) > No… the filter script is operating on the contents of the email - not the postfix mail log. I'd suggest you open the linked in email, and view it's source - that's what the filter script runs on. You could probably just do a regexp on e.g. elsif(/^X-LinkedIn-/) { $logger->debug("linked in spam stuff"); exit(0); } Considering a random email I have here from LinkedIn contains : Subject: Add skills and expertise like ……. X-LinkedIn-Template: suggested_skills X-LinkedIn-Class: TIK X-LinkedIn-fbl: m-vwEVIlxpMe6S2lEblahblahblahblahblahblahblahblahaU4gyFze1CwQBhcj4Nq_ From: LinkedIn <mes...@li...> Sender: mes...@bo... If you want to do a match on from, then : elsif(/^from:\sLinkedIn.*messages-noreply\@linkedin.com.*/i) { …. } would probably work (I've not tested this); the X-LinkedIn looks easiest to me :) as the from variant is longer. thanks, David. |
From: Tanstaafl <tan...@li...> - 2012-02-21 12:32:38
|
Hi David, Many thanks for your response, but a few follow-up questions... I actually think I just noticed that there may be a more appropriate place in vacation.pl for what I'm trying to do... Above that section where the headers get examined, there is this section: # Make sure the email wasn't sent by someone who could be a mailing # list etc; if it was, then we abort after appropriate logging. sub check_and_clean_from_address { my ($address) = @_; my $logger = get_logger(); if($address =~ /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i || $address =~ /\-(owner|request|bounces)\@/i ) { $logger->debug("sender $address contains $1 - will not send vacation message"); exit(0); } $address = strip_address($address); if($address eq "") { $logger->error("Address $address is not valid; exiting"); exit(0); } #$logger->debug("Address cleaned up to $address"); return $address; } This appears to be a much better section to do what I really think needs to be done.... First question: would the from= address that I saw in my postfix log be matched by the $address variable above? Anyway, my overall goal here is concerning the huge growth in these social networking sites - shouldn't vacation.pl specifically take these systems into account? Meaning, rather than us sysadmins just trying to keep up with these individually, shouldn't official support be added to vacation.pl for these services? There is Facebook, Twitter, LinkedIn, MySpace, and now Google+ (did I miss any?)... Next question: do you agree that this is the more appropriate place for checks for these kinds of services? I think these social networking services definitely fall into the category of 'etc' in the comments. So, I'm thinking we could modify that text to: # Make sure the email wasn't from a mailing list, an automated message # from a social networking site, etc; if it was, then we abort after # appropriate logging. Then, modify the code appropriately with as many known examples as possible. There should also be a formal process for us (users) to submit new strings for official inclusion, but these should absolutely be approved by someone who knows what they are doing and how these code sections in vacation.pl actually work. So, with this in mind, if I modified the above to, say, something like: if($address =~ /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i || $address =~ /\-(owner|request|bounce|bounces)\@/i ) { $logger->debug("sender $address contains $1 - will not send vacation message"); exit(0); } (I simply added 'bounce' before 'bounces') Would that catch the example I gave from linkedin, since it is from=blahblah.bounce.linkedin.com (bounce is singular, not plural)? Also - is that a 'contains' search? If so, I'm guessing I could remove the plural form (bounces), since that would also be matched by 'bounce'? Again, thanks for taking the time to discuss this, my only goal is to make vacation.pl better... Charles |
From: David G. <da...@co...> - 2012-02-21 13:02:54
|
> > Above that section where the headers get examined, there is this section: > > # Make sure the email wasn't sent by someone who could be a mailing > # list etc; if it was, then we abort after appropriate logging. > sub check_and_clean_from_address { > my ($address) = @_; > my $logger = get_logger(); > > if($address =~ > /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i > || > $address =~ /\-(owner|request|bounces)\@/i ) { > $logger->debug("sender $address contains $1 - will not send > vacation message"); > exit(0); > } > > First question: would the from= address that I saw in my postfix log be > matched by the $address variable above? > Yes. > Anyway, my overall goal here is concerning the huge growth in these > social networking sites - shouldn't vacation.pl specifically take these > systems into account? Meaning, rather than us sysadmins just trying to > keep up with these individually, shouldn't official support be added to > vacation.pl for these services? > Yes, it probably should. I suspect not many people are using it - hence there haven't been many patches/bugs/whatever reported. > Next question: do you agree that this is the more appropriate place for > checks for these kinds of services? I think these social networking > services definitely fall into the category of 'etc' in the comments. > > So, I'm thinking we could modify that text to: > > # Make sure the email wasn't from a mailing list, an automated message > # from a social networking site, etc; if it was, then we abort after > # appropriate logging. > > Then, modify the code appropriately with as many known examples as possible. > Yes. > > So, with this in mind, if I modified the above to, say, something like: > > if($address =~ > /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i > || > $address =~ /\-(owner|request|bounce|bounces)\@/i ) { > $logger->debug("sender $address contains $1 - will not send > vacation message"); > exit(0); > } > > (I simply added 'bounce' before 'bounces') > > Would that catch the example I gave from linkedin, since it is > from=blahblah.bounce.linkedin.com (bounce is singular, not plural)? > What you've added is looking for -bounce@ Which will not match bla...@bo... > Also - is that a 'contains' search? If so, I'm guessing I could remove > the plural form (bounces), since that would also be matched by 'bounce'? > No. The @ has to follow one of the things in the brackets (owner|request|bouce|bounces) thanks, David. |
From: Tanstaafl <tan...@li...> - 2012-02-21 14:56:55
|
On 2012-02-21 8:02 AM, David Goodwin <da...@co...> wrote: >> So, with this in mind, if I modified the above to, say, something like: >> >> if($address =~ >> /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i >> || >> $address =~ /\-(owner|request|bounce|bounces)\@/i ) { >> $logger->debug("sender $address contains $1 - will not send >> vacation message"); >> exit(0); >> } >> >> (I simply added 'bounce' before 'bounces') >> >> Would that catch the example I gave from linkedin, since it is >> from=blahblah.bounce.linkedin.com (bounce is singular, not plural)? > What you've added is looking for -bounce@ > > Which will not match bla...@bo... Oh!? Maybe I just realized... ok, so looking more closely, that section of code is assembling two strings separated by a '-', but only for the localpart of the sender address, correct? So, if I wanted to add a section to match on only something in the host part (ie, *@*$string*, can you provide the code to do that? Maybe something as simple as: if($address =~ /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i || $address =~ /\-(owner|request|bounces)\@/i || $address =~ /\(linkedin|facebookmail|twitter|myspace)/i) { $logger->debug("sender $address contains $1 - will not send vacation message"); exit(0); } I'm sure my code sample is wrong, but maybe you could tweak it? I'll be happy to provide a patch once I have a working/tested version. Thanks again David... |
From: Tanstaafl <tan...@li...> - 2012-02-21 17:43:50
|
On 2012-02-21 9:56 AM, Tanstaafl <tan...@li...> wrote: > Maybe something as simple as: > > if($address =~ > /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i > > || > $address =~ /\-(owner|request|bounces)\@/i { > $logger->debug("sender $address contains $1 - will not send > vacation message"); > exit(0); > > I'm sure my code sample is wrong, but maybe you could tweak it? Hmmm... this wouldn't work, because it would require a match on the localpart too, right? Or would it... Maybe add an elseif in there, so something like: if($address =~ /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i || $address =~ /\-(owner|request|bounces)\@/i { $logger->debug("sender $address contains $1 - will not send vacation message"); exit(0); elseif($address = /^*(linkedin|facebookmail|twitter|myspace)*/i) { $logger->debug("sender $address contains $1 - will not send vacation message"); exit(0); } ? |
From: David G. <da...@co...> - 2012-02-21 18:08:31
|
>> >> if($address =~ >> /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i >> >> || >> $address =~ /\-(owner|request|bounces)\@/i { >> $logger->debug("sender $address contains $1 - will not send >> vacation message"); >> exit(0); >> >> I'm sure my code sample is wrong, but maybe you could tweak it? > > Hmmm... this wouldn't work, because it would require a match on the > localpart too, right? Or would it... > > Maybe add an elseif in there, so something like: > > if($address =~ > /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i > || > $address =~ /\-(owner|request|bounces)\@/i ) { > $logger->debug("sender $address contains $1 - will not send > vacation message"); > exit(0); } > elseif($address = /^*(linkedin|facebookmail|twitter|myspace)*/i) { > $logger->debug("sender $address contains $1 - will not send > vacation message"); > exit(0); > } The above ought to work. I've added a missing ) on line 4 ($address =~ /.…….@/i ) <-- and a missing } after the 'exit(0)'. David. |
From: Tanstaafl <tan...@li...> - 2012-02-21 19:39:41
|
On 2012-02-21 1:07 PM, David Goodwin <da...@co...> wrote: >> > Maybe add an elseif in there, so something like: >> > >> > if($address =~ >> > /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i >> > || >> > $address =~ /\-(owner|request|bounces)\@/i ) { >> > $logger->debug("sender $address contains $1 - will not send >> > vacation message"); >> > exit(0); > } >> > elseif($address = /^*(linkedin|facebookmail|twitter|myspace)*/i) { >> > $logger->debug("sender $address contains $1 - will not send >> > vacation message"); >> > exit(0); >> > } > > > The above ought to work. I've added a missing ) on line 4 ($address =~ /.…….@/i )<-- > and a missing } after the 'exit(0)'. Cool, I'll give it a shot... Thanks! |
From: Tanstaafl <tan...@li...> - 2012-02-21 19:55:25
|
On 2012-02-21 2:39 PM, Tanstaafl <tan...@li...> wrote: > On 2012-02-21 1:07 PM, David Goodwin<da...@co...> wrote: >>>> Maybe add an elseif in there, so something like: >>>> >>>> if($address =~ >>>> /^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i >>>> || >>>> $address =~ /\-(owner|request|bounces)\@/i ) { >>>> $logger->debug("sender $address contains $1 - will not send >>>> vacation message"); >>>> exit(0); >> } >>>> elseif($address = /^*(linkedin|facebookmail|twitter|myspace)*/i) { >>>> $logger->debug("sender $address contains $1 - will not send >>>> vacation message"); >>>> exit(0); >>>> } >> >> >> The above ought to work. I've added a missing ) on line 4 ($address =~ /.…….@/i )<-- >> and a missing } after the 'exit(0)'. > > Cool, I'll give it a shot... Ok, applied the change, sent a test message to someone that I know who has vacation enabled (just to make sure normal vacations work properly), and got the following error: Feb 21 14:47:59 myhost postfix/pipe[8670]: BBD4F9A0CC2: to=<validuser#med...@au...>, orig_to=<val...@me...>, relay=vacation, delay=0.92, delays=0.29/0.01/0/0.63, dsn=5.3.0, status=bounced (Command died with status 255: "/var/spool/vacation/vacation.pl". Command output: elseif should be elsif at /var/spool/vacation/vacation.pl line 530. ^* matches null string many times in regex; marked by <-- HERE in m/^* <-- HERE (linkedin|facebook|twitter|myspace)*/ at /var/spool/vacation/vacation.pl line 530. syntax error at /var/spool/vacation/vacation.pl line 530, near ") {" Global symbol "$address" requires explicit package name at /var/spool/vacation/vacation.pl line 534. Global symbol "$address" requires explicit package name at /var/spool/vacation/vacation.pl line 534. Global symbol "$address" requires explicit package name at /var/spool/vacation/vacation.pl line 535. Global symbol "$address" requires explicit package name at /var/spool/vacation/vacation.pl line 536. Global symbol "$address" requires explicit package name at /var/spool/vacation/vacation.pl line 540. syntax error at /var/spool/vacation/vacation.pl line 541, near "}" Execution of /var/spool/vacation/vacation.pl aborted due to compilation errors. ) So, looks like it didn't like my wildcard? |