Skip to content

Instantly share code, notes, and snippets.

@clicktechnology
Created May 3, 2024 17:56
Show Gist options
  • Save clicktechnology/5dfdd0071975203d4960b304af72fb03 to your computer and use it in GitHub Desktop.
Save clicktechnology/5dfdd0071975203d4960b304af72fb03 to your computer and use it in GitHub Desktop.
process-mail.sh
#!/bin/bash
# $2 is the email sender. We want to autoreply to them
# $4 is our filter user email address, typically filter@localhost
# Check the parameters below are right for your system
SENDMAIL="/usr/lib/sendmail"
DOMAIN="YOUR-DOMAIN-NAME-HERE.com"
LOCAL_AUTOREPLY_ADDRESS="filter@localhost"
if [ "$4" = $LOCAL_AUTOREPLY_ADDRESS ]; then
echo "OK, I'll send a reply to |$2|"
printf '%s\n' "Subject: Autoreply from $DOMAIN" \
"From: Autoreply <autoreply@$DOMAIN>" \
"To: Recipient <$2>" \
"" \
"--------------------------------------------------------------------------------" \
" " \
" This is the autoresponder for $DOMAIN. Your mail was received!" \
" " \
"--------------------------------------------------------------------------------" | $SENDMAIL -oi -t
else
echo "Not an autoreply address."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment