Skip to content

Instantly share code, notes, and snippets.

@tpraxl
Created June 7, 2018 11:32
Show Gist options
  • Save tpraxl/6d5be3527490fb51f33ae5eafe747714 to your computer and use it in GitHub Desktop.
Save tpraxl/6d5be3527490fb51f33ae5eafe747714 to your computer and use it in GitHub Desktop.
Autorespond using IMAP on Uberspace 7 (U7)
|maildrop $HOME/.test-filter
############################################
# Autorespond using IMAP on Uberspace 7 (U7)
############################################
# Date: 2018-06-07
# Abstract:
# This script allows you to enable the autoresponder by creating an IMAP folder
# called "Autorespond" in the root of your IMAP folders (not in INBOX, but as
# a sibling of INBOX).
#
# Once the folder is present and it contains a message, the autoresponder is
# turned on and it will respond with the most recent message in this
# folder.
#
# Limitations:
# Notice that I couldn't find a way to turn off quoting of the original message.
#
# How-to:
# In the following script, we assume that you have created a mail user test:
#
# uberspace mail user add test
#
# Just replace "test" with your desired mail user name in this script.
#
# We also assume that your E-Mail-Adress is test@stardust.uber.space
# Just replace stardust with your host's name (e.g. klemola, taylor, etc),
# don't confuse it with the name of your Uberspace
# (the one, you have chosen yourself).
#
# If you are using an external domain, this will work as well. E.g. for
# test@mydomain.tld. You can specify test@mydomain.tld as the sender below as well.
#
# You should create one filter file for each autoresponder
# sender email address separately.
#
# Make sure that each filter file has access rights 600, otherwise it won't work:
# chmod 600 .test-filter
#
# Make sure that you use UNIX line-endings in this file, otherwise it won't work.
#
# Create the file .qmail-test with the following content (including the pipe):
# |maildrop $HOME/.test-filter
#
# If you want to debug the autoresponder, turn on logging
# by uncommenting the following line.
#
# logfile "$HOME/test-filter.log"
# Set the default Maildir
MAILDIR="$HOME/Maildir"
# Set the sender for the autoresponse
FROM="test@stardust.uber.space"
# If you're using a separate mail user (not the primary), we setup the MAILDIR
# accordingly
import EXT
if ( $EXT )
{
CHECKMAILDIR = `dumpvuser $EXT | grep '^Directory' | awk '{ print $2 }'`
if ( $CHECKMAILDIR )
{
MAILDIR="$HOME/$CHECKMAILDIR"
}
}
# Autoresponder rule
#
# Note: -N is useless when using -T replydraft. I couldn't find a way to disable
# quoting when using this reply format. Suggestions are welcome.
# See http://www.courier-mta.org/maildrop/mailbot.html
cc "| mailbot -T replydraft -l '$MAILDIR/.Autorespond' -N -A 'From: $FROM' /var/qmail/bin/qmail-inject -f ''"
# Receive the mail (the original mail goes into your INBOX)
to "$MAILDIR"
@jonashoechst
Copy link

In case you want to set the FROM header automatically (e.g. if there are multiple users that should be supported by this filter, the FROM address can be constructed as follows:

import EXT
import HOST
FROM="$EXT@$HOST"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment