Sponsored Content
Full Discussion: script to read mail
Top Forums Shell Programming and Scripting script to read mail Post 302348633 by jgt on Friday 28th of August 2009 08:07:59 PM
Old 08-28-2009
Add an alias in /etc/mail/aliases like the following
user: user, |/usr/user/myprocess

Run "newaliases"
Send an email to user . The entire email including headers will be used as standard input to the "myprocess" script.
The my process script should look something like:

while read line
do
if [ "a`echo $line|cut -c 1-8`" = "aSubject:" ]
#we add the "a" to the beginning of the test to ensure that the argument is not null
then
test=`echo $line|cut -d":" f2`
if [ "a$test" = "aGOODEMAIL" ]
then
run_my_script
fi
fi
done
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Tell UW-Imap to read /var/mail/mailbox ??

Hi, I've got UW-IMAP installed on Gentoo. I'm using EXIM as the transfer agent. EXIM is working fine (I think)... all incoming mail - external and internal goes to /var/mail/username file. I can verifiy this by reading this file directly with nano. Also, IMAPd is running. It lets me login... (2 Replies)
Discussion started by: d11wtq
2 Replies

2. UNIX for Dummies Questions & Answers

How to mark ALL mail items as read?

Hi guys. Does anyone know if there is a mail command that will allow you to flag all mail items as being read? I've checked out the man mail pages, but can't seem to find what I'm looking for. :confused: We are running UNIX AIX 5.2. Thanks in advance, Kev (3 Replies)
Discussion started by: Krispy
3 Replies

3. Shell Programming and Scripting

script to read from mail

Hi, I have a requirement in which I have to read mail from a unix text file and scan records having failed records (any number > 0) Firstly it should compare the file creation_date with sysdate if the dates match then do the checking for failed records sample file i/p Staged 0... (0 Replies)
Discussion started by: misenkiser
0 Replies

4. 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

5. UNIX for Advanced & Expert Users

How to read mail attachement

I want to read attachements sent to unix mail id and save the attachement in folder. I may receive the mails from different mail clients(outlook, lotus ..etc). Attachements are in CSV(comma saperate) format. Let me know the shell script code for this. Regards, Venkat (1 Reply)
Discussion started by: svenkatareddy
1 Replies

6. Shell Programming and Scripting

script to read mail on a mail server

Hi All, Is there any way Unix shell script can directly read a mail on a mail server (for eg. abc@xyz.com) and save it as a text file in a unix directory ? Thanks PRKS ---------- Post updated at 08:37 AM ---------- Previous update was at 08:36 AM ---------- I am using ksh (1 Reply)
Discussion started by: PRKS
1 Replies

7. UNIX for Dummies Questions & Answers

read mail question

how do I save a email I just read to a new file? Thanks. (3 Replies)
Discussion started by: drew211
3 Replies

8. OS X (Apple)

Read and manage mail under Terminal

When opening Terminal window under Mac OS Lion, I have a message saying I've got mail . It seems to be somewhere close to ~/Library/Server/Mail/Data/spool/ but I ignore what command to be typed in order to read it and suppress it later once read. (1 Reply)
Discussion started by: shub22
1 Replies

9. UNIX for Advanced & Expert Users

Read mail attachments in AIX

Hello All, Is there a way to read/view email attachments in AIX? Here's my scenario; I have users that will being scanning documents for digital storage. To make it easier for the users, I would like for them to scan and email the pdf version of the document directly to one of my AIX... (3 Replies)
Discussion started by: bbbngowc
3 Replies

10. Shell Programming and Scripting

How to Read mail in a UNIX server?

My unix server is somehow configured to send mail to any id in my network. However, how do I read the mails in my inbox. I can send mails using mailx -s However, when I try to check whether there is mail using mailx -e it shows invalid option. (2 Replies)
Discussion started by: srkmish
2 Replies
aliases(5)							File Formats Manual							aliases(5)

NAME
aliases - aliases file for sendmail SYNOPSIS
DESCRIPTION
The command (which is the same as see sendmail(1M)) builds the sendmail alias database from a text file. The default text file is Local addresses (local user names) are looked up in the alias database and expanded as necessary, unless the user name is preceded by a backslash When the aliases file contains multiple entries for a given alias, only the last entry is used. Except when the processing option (the send to me option) is set in the command or in the configuration file, the sender is not included in any alias expansions. For example, if sends a message to and the expansion of includes the message is not delivered to Each line of the alias text file must be of the form: Mailing lists can be continued onto multiple lines. Each continuation line must begin with white space. Lines beginning with # are com- ments. A mailing-list is a comma-separated list of one or more of the following: user-name Local user names occurring in alias expansions will themselves be looked up in the alias database unless they are preceded by backslash remote-address The remote address syntax understood by is configured in the configuration file, and typically includes the RFC-822-style and the UUCP-style filename This must be an absolute path name. appends a message to the file only if the directory in which it resides is readable and searchable by all, and only if the file already exists, is not executable, and is writable by all. pipes the message as standard input to the specified command. If command-line contains blanks, it must be enclosed in quotation marks (). For example, reads filename for a list of recipient addresses and forwards the message to each. For example, an alias such as: would read for the list of addresses making up the group. If a file named exists in a user's home directory and is owned by the user, redirects mail for that user to the list of addresses in the file. An address in a or file can be anything that can appear as a mailing-list in the alias text file. can run programs or write to files using file. This is controlled by the file. If the owner of the file lacks a valid shell as listed in file, the execution of such programs will be disallowed. The user can still execute such programs by placing the special string in the file. The alias database is examined before a recipient's file is examined. After aliasing has been done, local and valid recipients who have a file in their home directory will have messages forwarded to the list of users defined in that file. Aliasing occurs only on local names. Loops can not occur, since no message will be sent to any person more than once. Aliases defined in will NOT be expanded in headers from (see mailx(1)), but WILL be visible over networks and in headers from (see mail(1)). is only the raw data file. The actual aliasing information is placed into a binary format in the file using (see newaliases(1M)). A command should be executed each time the file is changed in order for the change to take effect. Note that the NIS alias maps are gener- ated by using which leaves and in the directory. AUTHOR
was developed by the University of California, Berkeley, and originally appeared in 4.0BSD. FILES
User's mail forwarding file raw data file for alias names database of alias names SEE ALSO
mail(1), mailx(1), makemap(1M), newaliases(1M), sendmail(1M). aliases(5)
All times are GMT -4. The time now is 03:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy