readme and logs

This commit is contained in:
Gnieark 2017-01-17 07:50:54 +01:00
parent c1032e4d5e
commit 29aedad2bd
3 changed files with 35 additions and 7 deletions

View File

@ -1,11 +1,29 @@
# trash-email-alias # trash-email-alias
a dovecot sieve 's script and configuration to generate random alias a dovecot sieve 's script and configuration to generate a temporary random alias
# usage # usage
Just send an email to the configured em-mail generator. It will respond you and indicate what is your alias. Just send an email to the configured em-mail generator. It will respond you and indicate what is your alias.
You can test it by sending a mail to [ getalias Arobaze tinad.fr ]
# Configure # Configure
Need dovecot and dovecot pigeon hole. You need an e-mail server with dovecot and sieve. The mail box structure is the classical one.
Add a colomn named "temporary" type Boolean, default 0 to the table alias. So alias table structure is:
+-----------+--------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------------------+-------+
| address | varchar(255) | NO | PRI | | |
| goto | text | NO | | NULL | |
| domain | varchar(255) | NO | | | |
| created | datetime | NO | | 0000-00-00 00:00:00 | |
| modified | datetime | NO | | 0000-00-00 00:00:00 | |
| active | tinyint(1) | NO | | 1 | |
| temporary | tinyint(1) | NO | | 0 | |
+-----------+--------------+------+-----+---------------------+-------+
On /etc/dovecot/dovecot.conf my plugin section looks like: On /etc/dovecot/dovecot.conf my plugin section looks like:
plugin { plugin {
@ -29,4 +47,8 @@ On /etc/dovecot/dovecot.conf my plugin section looks like:
(...) (...)
} }
Change your mysql credentials on cron/purge.sh and execute/genalias.sh
In my case, this files are owned by the unix user "dovecot".
Add purge.sh on your crontab. Evrey 10 minutes is enougth.

View File

@ -6,9 +6,12 @@ MYSQLPATH="/usr/bin/mysql"
MYSQLDB="postfix" MYSQLDB="postfix"
MYSQLUSER="postfix" MYSQLUSER="postfix"
MYSQLPWD="******" MYSQLPWD="******"
LOGGERPATH="/usr/bin/logger"
LOGFILE="/var/log/genalias.log"
TTL="3600" TTL="3600"
$MYSQLPATH -u $MYSQLDB -p$MYSQLPWD << EOF $MYSQLPATH -u $MYSQLUSER -p$MYSQLPWD $MYSQLDB<< EOF
UPDATE alias UPDATE alias
SET active='0' SET active='0'
WHERE DOMAIN='tinad.fr' WHERE DOMAIN='tinad.fr'
@ -16,3 +19,6 @@ $MYSQLPATH -u $MYSQLDB -p$MYSQLPWD << EOF
AND created < (UNIX_TIMESTAMP() - $TTL) AND created < (UNIX_TIMESTAMP() - $TTL)
AND temporary='1'; AND temporary='1';
EOF EOF
$LOGGERPATH -s "Inactivate temporary alias older than 1 hour" 2> $LOGFILE
exit 0

View File

@ -20,6 +20,8 @@ MYSQLPWD="******"
OPENSSLPATH="/usr/bin/openssl" OPENSSLPATH="/usr/bin/openssl"
DOMAIN="tinad.fr" DOMAIN="tinad.fr"
LOGGERPATH="/usr/bin/logger" LOGGERPATH="/usr/bin/logger"
LOGFILE="/var/log/genalias.log"
#escape mail: #escape mail:
printf -v MAIL "%q" "$1" printf -v MAIL "%q" "$1"
@ -67,7 +69,5 @@ ALIASFULL=`$MYSQLPATH -B -u $MYSQLUSER -p$MYSQLPWD -D $MYSQLDB --disable-column-
fi fi
printf "Hi, Your requested alias is $ALIASFULL, You will receive all mails sending to this alias during one hour from now. Thanks for using this service." printf "Hi, Your requested alias is $ALIASFULL, You will receive all mails sending to this alias during one hour from now. Thanks for using this service."
$LOGGERPATH -s "Activate alias $ALIASFULL FOR $MAIL" 2> $LOGFILE
$LOGGERPATH -i -p genalias.info "Activate alias $ALIASFULL FOR $MAIL" exit 0
exit 0