Have you ever had the need to read standard input in a bash script, for example
cat /var/log/message | mycoolbashscript.sh Well i did when wrapping msmtp for use with mutt see the example bellow
#!/bin/bash all=`cat "/dev/stdin"` if `/sbin/ifconfig eth0 | /bin/grep "inet addr" | /usr/bin/awk -F: '{ print $2 }'' | /usr/bin/awk '{ print $1 }'' | /bin/grep -qE '172\.31|32\.[0-9]{1,3}\.[0-9]{1,3}'`; then echo "$all" | tsocks msmtp -a account $* else echo "$all" | msmtp -a account $* fi I then setup mutt to use this as the sendmail binary set sendmail="~/utils/sendmail.
I receive a lot of email as im a system administrator in order to handle this i prefer to use Mutt. One problem, Mutt sucks when using imap connections. In order to over come this you can use a nice little util called offlineimap that with sync a imap server to a local folder in mail dir format.
So the flow of mail into my computer is now Imap Server -> Offlineimap -> Mutt -> Offlineimap -> Imap Server
My last article covered by original mail setup after some usage i have tweaked it even more so i have to do even less.
I have now introduced imapfilter that can move messages to the correct mail folder before i run offlineimap.
First you need to setup ~.imapfilter/config.lua
{% codeblock lang:ini %} – Options – options.timeout = 120 options.subscribe = true – Accounts – Account = IMAP { server = ‘mail.