Sponsored Content
Top Forums Shell Programming and Scripting extract bulk emails into a single flat file Post 302103800 by sb008 on Sunday 21st of January 2007 05:37:04 PM
Old 01-21-2007
Email boxes are already in a flat file format.

If you want to spilt the mail into seperate files on a daily base do something like this:

Create a ".forward" file in the home directory of the account which receives the mail.

Notice the DOT in front of forward.

The ".forward" file could look like something like this:

cat .forward
---------------------------------------------
"|<some path>/splitmail.sh"
---------------------------------------------

where <some path> needs to be replaced by the actual path where the script "splitmail.sh" is located.

The ".forward" file will cause the email to be send to the script "splitmail.sh".

The "splitmail.sh" script could look like something like this:

cat splitmail.sh
---------------------------------------------
#!/usr/bin/ksh
DATE=`date +%Y%m%d`

cat - >> <some path>/mail.${DATE}
---------------------------------------------

Replace <some path> by the location where you want the files to be created.

This is just a basic example. As a result all mail will end up in files on a day base. So no mail will be present in the "normal" inbox.

It is possible to have it both, so as well in seperate files as well as still in the inbox.

See the manual pages for "forward".

There are programs/tools out there which allow you to manipulate mail in a far more complex way. One of them is "procmail".
 

10 More Discussions You Might Find Interesting

1. Programming

How to read specific lines in a bulk file using C file Programming

Please Help me I have a Bulk file containing Hex data I want to read specific lines from that bulk file by ID number. example ID DATE Time data 14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223... (10 Replies)
Discussion started by: rajan_ka1
10 Replies

2. UNIX for Advanced & Expert Users

how to unzip and extract tar file in single command

In order to save diskspace and avoid of disk full during unzip then extract the tar file is there any tar unzip command would unzip and extract tar at the same time (test123.tar.gz) thank in advance (6 Replies)
Discussion started by: darkrainbow
6 Replies

3. Shell Programming and Scripting

tar: extract single file to different filepath

Hi, This is my first post here - I'm hoping I can get some help! I have searched these forums and othersand not getting anything that works. I am trying to extract a single file from a tar archive to a diffierent location than it will default to. For example my tar log shows me ... a... (3 Replies)
Discussion started by: littleIdiot
3 Replies

4. UNIX for Dummies Questions & Answers

tar command help -- extract single file

Hi, I want to view/display the contents of one file in tar file. For example if the tar file is sam.tar.gz and one of the file inside is E1.txt, how do i view the contents of this E1.txt file. Olso if I want to extract the E1.txt file only from sam.tar.gz how can i do that. Thanks in... (7 Replies)
Discussion started by: icefish
7 Replies

5. UNIX for Advanced & Expert Users

What is command to extract single file from an archieve?

I just want to extract one sigle file from an .ear archieve instead of extracting whole ear. Can anyone help me on this? (4 Replies)
Discussion started by: harshal_dcx
4 Replies

6. Shell Programming and Scripting

Find and Extract all emails from my server

My linux version is: Linux version 2.6.9-89.0.9.ELsmp (gcc version 3.4.6 20060404 (Red Hat 3.4.6-11)) My problem is simple (lol) I need find and extract all e-mail from my server. I know how to extract the e-mail from a text file, the problem is: Where to find the e-mails? How to find all... (2 Replies)
Discussion started by: mauricio_yan
2 Replies

7. Shell Programming and Scripting

Merging the flat files into a single file

Hi, My requirement is search for the flat files in the location that are generated in a day and merge them into a single flat file. In the merged file as well particular column value should go into particular column. awk 'NR=1 FNR>1' $(ls -rt flatfile1_v_*) when i use this command for... (4 Replies)
Discussion started by: srikanth_sagi
4 Replies

8. UNIX for Dummies Questions & Answers

[Solved] How to extract single and duplicate lines from file?

Hi, I need help! I have two files, one containing a list of codes and the other a list of codes and their meaning. I need to extract from file 2 all the codes from file 1 into a new file. These are my files: File1: Metbo Metbo Memar Mth Metbo File2: Metbo Methanoculleus... (3 Replies)
Discussion started by: Lokaps
3 Replies

9. Shell Programming and Scripting

Extract a single file from a tar file to another directory

Hi, I need to extract a single file from a tar file to another directory. So far I have this: This one extract a single file to same directory: tar -xvf filename.tar ./file.txt I tried this but its not working tar -xvf filename.tar /home/dir ./file.txt or this: (6 Replies)
Discussion started by: erin00
6 Replies

10. Shell Programming and Scripting

Oracle table extract: all columns are not converting into pipe delimited in flat file

Hi All, I am writing a shell script to extract oracle table into a pipe dilemited flat file. Below is my code and I have attached two files that I have abled to generate so far. 1. Table.txt ==> database extract file 2. flat.txt ==> pipe delimited after some manipulation of the original db... (5 Replies)
Discussion started by: express14
5 Replies
splitmail(1)                                                  General Commands Manual                                                 splitmail(1)

NAME
splitmail - Split a large mail message into MIME-compliant partial messages SYNOPSIS
splitmail [-d] [-v] [-s splitsize] [-p prefix] [-i id-suffix] [file-name] DESCRIPTION
The splitmail program will take an email message and break it up into smaller pieces using the "message/partial" type defined by MIME, the proposed Internet standard for multimedia mail formats. By default it will take the message either from standard input or the named file, and will produce a set of partial message files with names like "/tmp/split.1" for the first part, and so on. The prefix "/tmp/split." can be overridden using the "-p" option. If the -d option is specified, the mail will actually be delivered. If -v is specified, the verbose flag will be passed to sendmail. The -i option can be used to make splitmail generate the pieces with similar (but not identical) message-id fields, in a format which allows them to be easily correlated with one another and which end with the suffix provided on the command line after -i. The default chunk size for spliting messages is 250000 at most sites, though this is also a compile-time option. This can be overriden with the -s switch, or with the environment variable SPLITSIZE. Messages smaller than the chunk size will not be turned into partial messages, but will be written to a single file or delivered as a sin- gle message. ENVIRONMENT
SPLITSIZE overrides the default chunk size. Setting SPLITSIZE to, say, 4000000 will effectively ensure that your messages are unlikely ever to be split, but it may cause them to be rejected by some mail transport software. SEE ALSO
mailto(1), metamail(1) BUGS
If the size of the input is just on the fencepost, and if it is coming from a file rather than standard input, splitmail will sometimes estimate the number of parts wrong and will have to write out an extra part. This is harmless but annoying. It is especially annoying if the estimate was 2 but the real number was 1. COPYRIGHT
Copyright (c) 1992 Bell Communications Research, Inc. (Bellcore) Permission to use, copy, modify, and distribute this material for any purpose and without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies, and that the name of Bellcore not be used in advertising or publicity pertaining to this material without the specific, prior written permission of an authorized representative of Bellcore. BELLCORE MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. AUTHOR
Nathaniel S. Borenstein, Bellcore Release 1 splitmail(1)
All times are GMT -4. The time now is 09:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy