Email Auto Responder - inotifywait
I will be away from the office next week so I decided I would look at how auto responders work, since the university have switched to Office365. I was disappointed - there is no way to send plain text as an auto response.
I decided to write my own… Hopefully it will not respond automatically to mailing lists (it shouldn't, since mailing lists typically do not change the
To header), but it may respond to newsletters.
#!/bin/bash fromaddr="Aaron Jackson <firstname.lastname@example.org>" base=~/Maildir/nottingham/INBOX/new inotifywait -m $base -e create -e moved_to | while read path action file; do # Read the email and extract the header. mail=$(cat "$base/$file" | sed '/^$/q') # Check to make sure that the email is being sent directly to # me, not to a mailing list. to=$(echo "$mail" | grep -ie ^CC: -e ^To: | grep -ie aaron.jackson -e psxasj) if [[ $(echo "$to" | wc -l) -eq 0 ]]; then continue fi # Get the sender's address and send the email. sender=$(echo "$mail" | grep -i ^From: | cut -b7-) cat ~/.vacation.msg | mail -r "$fromaddr" -s "Auto Reponder" "$sender echo "Auto response sent to $sender" done
While testing this, I was trying to figure out why sSMTP was sending mail via the school's mail server. It turns out that it looks up the A records for
mail. <network name> (i.e.