linux - Parse mail's body using mailx and bash scripting -


i trying automate part of work using emails.is there method available using mailx , bash can use extract mail's body?

if mail delivered local user account sendmail-like mta, can use procmail parse email it's being delivered.

on system using, sendmail examine ~/.forward file, had in ~username/.forward

# pipe incoming mail procmail # ref: http://www.panix.com/~elflord/unix/procmail.html # ref: http://porkmail.org/era/procmail/mini-faq.html#forward "|ifs=' ' && p=/usr/local/bin/procmail && test -x $p && exec $p -f- || exit 75 #username" 

then, ~username/.procmailrc contained:

# procmail tutorial: http://tldp.org/ldp/lg/issue14/procmail.html  path=/usr/local/bin:/bin:/usr/bin maildir=$home/mail default=$home/mail/inbox logfile=$home/procmail.`date +%y-%m`.log shell=/usr/bin/ksh  my_xloop='x-loop: username@hostname.subdomain.example.com' my_recipient='mailing.list@example.com'   ############################################################################# # if email comes client specific subject, # send copy of message processing script, ,  # carry on next recipe  :0c * ^from:.*@clientdomain\.invalid * ^subject:.*account.*(request|access|approval) | $home/bin/process_account_request_email.pl | \   mailx -s "account request results" $my_recipient   ############################################################################# # forward mail mailing list :0 * ! ^$my_xloop {     # add header     # 'f' = filter: pass message program , continue processing results      # 'h' = pass message headers program     # 'w' = wait program return     :0fhw     | formail -a "$my_xloop"      # forward message     # 'c' = send copy recipient , continue processing     :0c     ! $my_recipient }  # if here, message has x-loop header. # let fall $default 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -