LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-27-2004, 01:04 AM   #1
Jinkzer
LQ Newbie
 
Registered: Jun 2003
Location: Stockholm Sweden
Distribution: Gentoo, Slackaware, Flux, KDE
Posts: 20

Rep: Reputation: 0
Extracting mail attachment filename


What I want to do is to get my mail-systems to somehow give me the filename of the attachment(s) included with a mail. Either in the maillog or in a separate logfile for statistical presentation.

At the mailgate Im using postfix+amavis+spamassassin.

If I set a loglevel of 5 in amavis I see the filename in the maillog but there is now heaps of information (debug) i don't need and it's probably not that effective to run in debug-mode.

Mailserver is using sendmail but I would like to get the filename logging done at the mailgw.

Can any of the installed software do this or is there some other tool I can get to work with postfix/amavis?

Tried to get it working with procmail but..man...my girlfriend kills me if I stay up tapping on this keyboard one more night...

Thanks.
 
Old 02-27-2004, 01:09 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
What about just passing it through another script like:
Code:
#!/usr/bin/perl

# Open the log file for writing
open(LOG, ">>/var/log/attach.log");
# Read the input
while(<STDIN>){
# Look for attachment filenames
($file) = $_ =~ /filename="(.*)"/;
# If one was found then write it to the log
if($file){print LOG $file."\n"}
# Pass the untouched input back out again
print $_;
}
# Close the log file
close(LOG);

exit;
 
Old 02-27-2004, 04:24 PM   #3
Jinkzer
LQ Newbie
 
Registered: Jun 2003
Location: Stockholm Sweden
Distribution: Gentoo, Slackaware, Flux, KDE
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks mate! I'll try it tomorrow!
 
Old 02-28-2004, 08:07 AM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I should probably add that although the above will most likely work you should add some file locking and perhaps not actually open the log each time unless needed (although only open it once if required many times).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Attachment size hinetvenkat Linux - Security 3 12-26-2004 08:05 AM
mail -a would not work to send e-mail attachment saavik Linux - Networking 3 12-18-2003 09:33 AM
mail with attachment joseph Linux - Networking 1 08-31-2003 10:01 PM
extracting -filename.tar.gz- zokter Linux - Newbie 3 06-29-2003 06:18 AM
Procmail Store Mail Attachment mark@mark-goebl Linux - Software 1 01-09-2003 10:01 PM


All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration