Sponsored Content
Full Discussion: Email formatting
Top Forums Shell Programming and Scripting Email formatting Post 42868 by norsk hedensk on Wednesday 5th of November 2003 05:43:52 PM
Old 11-05-2003
Email formatting

ok, does anyone know how i can strip out fields i dont want from a mail spool file (eg: /var/mail/usermailbox) and dump to standard output (or file with > filename) ?? i tried using a bunch of grep -v 's but i realized that has two main problems, first of all, if anyone types the text im grepping out it will get removed, so i could tell grep to do it only once with -m 1 and so on, but there is going to be many emails in the mailbox.

so what i need is something like this:

Code:
From joe@farragutmarine.com  Tue Nov  4 22:34:54 2003
Return-Path: <joe@farragutmarine.com>
Delivered-To: main@farragutmarine.com
Received: from 192.168.1.103 (dynip4 [192.168.1.103])
        by farragutmarine.com (Postfix) with ESMTP id 0CD261700B
        for <main@farragutmarine.com>; Tue,  4 Nov 2003 22:34:54 -0500 (EST)
From: joe@farragutmarine.com
To: main@farragutmarine.com
Subject: This is a test
Date: Tue, 4 Nov 2003 23:12:40 -0500
User-Agent: KMail/1.5.1
MIME-Version: 1.0
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200311042312.40075.joe@farragutmarine.com>

This is a test, lets see if i can get this thing working.

now please keep in mind that there will be multiple emails in the mailbox. the fields in BOLD are the fields id like to keep.


i dont expect anyone to write out a whole script for me, just someone to point me in the right direction.

thanks !
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies

2. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

3. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

4. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

5. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

6. Windows & DOS: Issues & Discussions

email from *nix to Exchange - text formatting issue

Oracle Linux 5.6 x-86-64 (Red Hat derivitive) I have several shell scripts that capture output to a log file, then use that log file as the source of an email. For a very simplified example: echo Today is `date` >> $logfile /bin/mail -s "$subject" "$sendto" < $logfile (yes, $subject... (6 Replies)
Discussion started by: edstevens
6 Replies

7. Shell Programming and Scripting

[Solved] Sending a HTML email from cli loses formatting.

Hi, I have a .sh file, to email a report of our backups from a linux machine. It looks like this (minus a few bits): echo "HELO $host.$domain" sleep 1 echo "mail from: vdrreport@$domain" sleep 1 echo "rcpt to:$mailto" sleep 1 echo "data" sleep 1 echo "subject: $host VDR-Report... (2 Replies)
Discussion started by: cognito
2 Replies

8. UNIX for Dummies Questions & Answers

Formatting The Email Output

Hello All, When i use the single quotes around the variables i am getting each line in the array as seperate in the email as shown in code2 & output2. But i don't want those single quotes to be printed but each array element should be printed as seperate line as when i remove those single quotes... (1 Reply)
Discussion started by: Ariean
1 Replies

9. UNIX for Dummies Questions & Answers

Email formatting gets disturbed because of screen resolution

Hi friends, I have written a shell script which send a report to email address everyday. The report is generated on UNIX server every day, Generated report is sent to 25 users through cron. All 25 users have set different screen resolution for their monitor. The email looks wel formatted for... (4 Replies)
Discussion started by: Nakul_sh
4 Replies

10. Shell Programming and Scripting

Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping my code ( echo "From: $FROM" echo "To: $MAILTO" echo "CC: $CC" echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo 'Content-Type: multipart/mixed;... (6 Replies)
Discussion started by: mirwasim
6 Replies
PAM_MAIL(8)							 Linux-PAM Manual						       PAM_MAIL(8)

NAME
pam_mail - Inform about available mail SYNOPSIS
pam_mail.so [close] [debug] [dir=maildir] [empty] [hash=count] [noenv] [nopen] [quiet] [standard] DESCRIPTION
The pam_mail PAM module provides the "you have new mail" service to the user. It can be plugged into any application that has credential or session hooks. It gives a single message indicating the newness of any mail it finds in the user's mail folder. This module also sets the PAM environment variable, MAIL, to the user's mail directory. If the mail spool file (be it /var/mail/$USER or a pathname given with the dir= parameter) is a directory then pam_mail assumes it is in the Maildir format. OPTIONS
close Indicate if the user has any mail also on logout. debug Print debug information. dir=maildir Look for the users' mail in an alternative location defined by maildir/<login>. The default location for mail is /var/mail/<login>. Note, if the supplied maildir is prefixed by a '~', the directory is interpreted as indicating a file in the user's home directory. empty Also print message if user has no mail. hash=count Mail directory hash depth. For example, a hashcount of 2 would make the mail file be /var/spool/mail/u/s/user. noenv Do not set the MAIL environment variable. nopen Don't print any mail information on login. This flag is useful to get the MAIL environment variable set, but to not display any information about it. quiet Only report when there is new mail. standard Old style "You have..." format which doesn't show the mail spool being used. This also implies "empty". MODULE TYPES PROVIDED
The session and auth (on establishment and deletion of credentials) module types are provided. RETURN VALUES
PAM_BUF_ERR Memory buffer error. PAM_SERVICE_ERR Badly formed arguments. PAM_SUCCESS Success. PAM_USER_UNKNOWN User not known. EXAMPLES
Add the following line to /etc/pam.d/login to indicate that the user has new mail when they login to the system. session optional pam_mail.so standard SEE ALSO
pam.conf(5), pam.d(5), pam(8) AUTHOR
pam_mail was written by Andrew G. Morgan <morgan@kernel.org>. Linux-PAM Manual 09/19/2013 PAM_MAIL(8)
All times are GMT -4. The time now is 09:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy