Solved

Get a mail as a file on Linux

Posted on 2013-05-28
5
441 Views
Last Modified: 2013-05-29
Would like to check certain mails daily with Shell script on Linux env. One way is to dump one mail satisfying certain conditions into a file and process it with shell commands, and then loop each mail. How to do that? Any gurus shed some light on it?
Thanks in advance.
0
Comment
Question by:jl66
5 Comments
 
LVL 22

Expert Comment

by:blu
Comment Utility
Are the mails on a server or local on the file system?
0
 

Author Comment

by:jl66
Comment Utility
local.
0
 
LVL 20

Accepted Solution

by:
Daniel McAllister earned 400 total points
Comment Utility
Your solution is dependent upon the mail server software you use. Specifically, the way the mail software stores messages.

In general *nix systems store mail messages in 1 of 2 ways:
 mbox -- essentially one giant file with all mail message contents in that one file. Each Inbox or other "folder" is a separate file.
 maildir -- a directory heirarchy, so your folders are folders, and each message is an individual file. Message status is usually managed by manipulating the filename.

So, to begin to answer your question appropriately, we'll need to start with what mailbox type your server uses!

Dan
IT4SOHO
0
 
LVL 23

Assisted Solution

by:nemws1
nemws1 earned 100 total points
Comment Utility
Have you used or heard of procmail?  You can set up a .forward file with procmail and based on rules either have an e-mail sent to your inbox or have it processed through a shell script.

This is even covered (briefly) in the procmail FAQ:
http://partmaps.org/era/procmail/mini-faq.html#rtfm
0
 

Author Closing Comment

by:jl66
Comment Utility
Thanks for the tips. I figured out the way to do the script.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Resolve DNS query failed errors for Exchange
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now