Parse /var/mail


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Parse /var/mail
# 1  
Old 12-01-2009
Parse /var/mail

Hi all...

We have a box that receives a lot of incoming emails. I have a .procmailrc file that in turn invokes a python script, which process each of these incoming email. All is nice and good.

However, before the .procmailrc and python script were in place, we still were receiving emails and those emails were obviously not processed by the py script. The emails are stored under /var/mail/ as a single file. Now, I need to run my script on these emails. I was considering changing the script to handle multiple emails but it will result in too many changes and might break it.

I was wondering if there is a way using which I can feed one email (from /var/mail/my-mail) at a time to the python script?

"Formail" was something I was told to look into. I am also checking that. Does anyone know anything about formail?

Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Var in nawk script parse incorrectly

I'm writing a Texas Hold'em script in bash v3.00.16(1) to learn more about awk/nawk scripts and regex expressions by trying to randomize a list of names using awk's rand function. The problem is that the elements in the var convert to a single element in the nawk script. I've tried several things,... (4 Replies)
Discussion started by: HexKnot
4 Replies

2. Shell Programming and Scripting

importance of /var/mail

Hi When an entry will be made to the file /var/mail/<user-id> . I have 100 scripts under a specific user id(dgircc) in cron .SO inrder to check the whether the script has sucessfully run or not and if not to generate an email if i mention the code like #!/bin/ksh -p 2 fsize=`ls -lrt... (0 Replies)
Discussion started by: mskalyani
0 Replies

3. Cybersecurity

Last 24 hours of /var/mail/root/

Hi there, I'm using this command line to get a daily mail through crontab with the content of /var/mail/root: mailx -s "Test My Server" mymail@mail.com </var/mail/root and it works fine, but I'd like to get only the information updated in the last 24 hours. Thanks in advance for any... (2 Replies)
Discussion started by: Giordano Bruno
2 Replies

4. UNIX for Advanced & Expert Users

Mail going to /var/spool/mqueue instead of being sent

Hello, I have a bunch of cron jobs in the crontab. For some reason mail from the cron jobs started going to /var/spool/mqueue instead of being sent. Does anyone know why mail from cron jobs would go to the queue instead of being sent? (9 Replies)
Discussion started by: xadamz23
9 Replies

5. UNIX for Dummies Questions & Answers

/var/spool/mail

Hi, How can i get my mail on either /var/spool/mail or /var/mail? I use mail and sendmail command to send mail. But everytime I send mail it comes to my outlook inbox and when I check with mail command I get the message "No mail for siba". (Note siba is my user Id.) (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

6. UNIX for Dummies Questions & Answers

/VAR/SPOOL/MAIL question

Hi, We have all the user account in a home direcory where their mail is stored and retrieved by email clients. We do however have /var/spool/mail with all the user accounts in it as well Our sendmail.cf is configured to use /var/spool/mqueue as the queue so .what is /var/spool/mail being used... (3 Replies)
Discussion started by: mojoman
3 Replies

7. UNIX for Dummies Questions & Answers

How do I read mail in /var/spool/mail?

How can I read mail sent to /var/spool/mail? I do not have pine installed so forget about that...is there some generic utility I can use? (3 Replies)
Discussion started by: mojoman
3 Replies

8. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

9. UNIX for Dummies Questions & Answers

Can I zero var/spool/mail/mail

The mail file in the directory var/spool/mail is very large. Can I zero this (>) without losing any unopened mails there may be? There are about 10 mail accounts. Using RedHat Linux. Thanks in advance. (0 Replies)
Discussion started by: dennisheazle
0 Replies

10. Shell Programming and Scripting

READING mail from /var/mail/user

Hello guys, I'm in desperate need. I need to write a script that behaves like a "mail" shell program. I've a base of the program -menu and so on, but what I cannot do is how to read messages from /var/mail/user. I would like to separate them as "mail" program does, but I;m just a newbie and... (21 Replies)
Discussion started by: petoSVK
21 Replies
Login or Register to Ask a Question
COURIERPERLFILTER(8)					      Double Precision, Inc.					      COURIERPERLFILTER(8)

NAME
courierperlfilter - Sample Perl-based mail filter SYNOPSIS
filterctl [[start] | [stop]] [perlfilter] DESCRIPTION
This is an example global mail filter that uses an embedded Perl script. "Embedded" means that the Perl interpreter is loaded once, and the same Perl code is repeatedly called to accept or reject incoming messages, one by one. Perl filtering is relatively time consuming (compared to filtering in C or C++), and excessive delays in mail filters result in incoming mail being deferred (rejected with a temporary error code). Therefore the perlfilter wrapper can create multiple perlfilter processes, so that multiple processes are used to filter incoming mail. perlfilter requires Perl 5.004 or higher. The best way to create a Perl filter is to start with the sample filter, /usr/lib/courier/perlfilter-example.pl. This filter reject messages that contain an excessively long Date: header (designed to crash certain poorly-written mail clients). Use it as a basis for writing your own filter. You can install your filter in any convenient location, then initialize the /etc/courier/filters/perlfilter configuration file, as described below. Run filterctl start perlfilter to activate filtering (if necessary, run courierfilter start to start the mail filtering subsystem). Setting up a Perl script Most of the ugly details of connecting the Perl script to Courier's mail filtering engine is taken care of by the sample perlfilter-example.pl script. One big no-no: the script MAY NOT change the current directory. Anything else goes, for the most part. Loading other modules and classes, pretty much anything else you can do with Perl, is allowed. The Perl script, just like any other mail filtering module, receives a pointer to a data file and one or more control files, each time a message is submitted to Courier for delivery. The sample script calls the filterdata() function to process the data file. The data file contains the actual message. The filtercontrol() function is called to process each control file. The control file contains recipient and message metadata. There may be more than one control file for each message. The example script includes an implementation of filterdata() that blocks messages with corrupted headers. The example script doesn't do anything interesting with filtercontrol(). filterdata() and filtercontrol() must return an empty string if no serious objections are raised for this message. Any other return string is interpreted as an SMTP-style error code that is used to reject the message. Care must be taken that any error messages are formatted strictly according to the format of SMTP error messages (even though the message may not actually come in via SMTP). CREDITS
A lot of the Perl glue code is based on examples from the perlembed manual page, and other sources. FILES
perlfilter uses the following configuration files. Changes to the following files do not take effect until the filter has been stopped and restarted. /etc/courier/filters/perlfilter-mode If this file exists and contains the word "all", perlfilter will create its socket in /var/lib/courier/allfilters, otherwise the socket will be created in /var/lib/courier/filters, see courierfilter(8)[1] for more information. /etc/courier/filters/perlfilter-numprocs This file contains a number that sets how many perlfilter processes are created. The default is 5 processes. There's always an extra perlfilter process that's used to clean up crashed child processes. /etc/courier/filters/perlfilter This file MUST exist and it must contain a single line of text with the filename of the Perl script to load. /usr/lib/courier/perlfilter-example.pl This is a sample Perl script of the kind that /etc/courier/filters/perlfilter points to. Use it as an example of writing your own Perl filters. Please exercise good judgment in writing Perl-based filters. They should be reasonably fast, and do not allocate megabytes of memory. They should not be very promiscuous in creating global Perl variables, and should clean up after themselves. The current Perl wrapper does not destroy the Perl symbol table after each call to the filter script. However, do not take that for granted. This may change in the future. SEE ALSO
courierfilter(8)[1]. AUTHOR
Sam Varshavchik Author NOTES
1. courierfilter(8) [set $man.base.url.for.relative.links]/courierfilter.html Courier Mail Server 04/04/2011 COURIERPERLFILTER(8)