Automatická emailová odpověď – Linux / Postfix

Velmi užitečný článek jak realizovat, velmi jednoduše automatické odpovědi na postfixu.

Instalace a nastavení byly bez problémů.

http://blog.alexos.com.br/2009/10/postfix-habilite-auto-replyvacation-usando-o-autoresponse/

Protože příspevěk už není funkční radši jsem ho sem přepsal …

Autoresponse

***Autoresponse is deprecated***

Sorry everyone! I’m officially ending the autoresponse project. I simply haven’t had the spare time to develop this software further… it had a decent run and thanks to everyone who actually used it in production, your feedback was instrumental in helping make it stable and usable. –musashiXXX 3 December 2012

Autoresponse is an autoresponder for the Postfix MTA.The autoresponse script is called by postfix pipe(8) in the same way that one would call a content filter. As a side note, it is possible to do some minor content filtering with this script however that would require, at the least, intermediate level (or greater) knowledge of bash and some minor hacking of the autoresponse script–this will not be covered here.

Click here to download the latest version (1.6.3).

Installation:

To install and configure, execute the following actions as root:

1
2
3
4
5
useradd -d /var/spool/autoresponse -s `which nologin` autoresponse
mkdir -p /var/spool/autoresponse/log /var/spool/autoresponse/responses
cp ./autoresponse /usr/local/sbin/
chown -R autoresponse.autoresponse /var/spool/autoresponse
chmod -R 0770 /var/spool/autoresponse

Then, edit /etc/postfix/master.cf and look for the following line:

1
smtp      inet  n       -       n       -       -       smtpd<

And add the following line, directly below it (make sure this line begins with at least one whitespace character):

1
-o content_filter=autoresponder:dummy

Add the following two lines (make sure the second one begins with whitespace) somewhere near the bottom of the file under the section “# Other external delivery methods.”

1
2
<pre>autoresponder unix - n n - - pipe
     flags=Fq user=autoresponse argv=/usr/local/sbin/autoresponse -s ${sender} -r ${recipient} -S ${sasl_username} -C ${client_address}

Before we go any further, you need to know that there is a difference between ${original_recipient} and ${recipient}. The former expands to the complete recipient address before any address rewriting or aliasing; the latter expands to the complete recipient address after rewriting/aliasing. Some users say that the ${original_recipient} works great for them, and others swear by using ${recipient}. When in doubt, use ${recipient}. For more information, see the manpage pipe(8).

Save and quit, then, run the following command:

1
postconf -e 'autoresponder_destination_recipient_limit = 1'

Restart postfix:

1
/etc/init.d/postfix restart

Additional Notes:

[a] These steps are specific to Fedora and Ubuntu however they will probably work on other distros as well.

[b] If you want local users to be able to create their own auto responses (from the shell), you must put them in the ‘autoresponse’ group, see the manpage group(5) for instructions on how to go about this.

If step #7 seems counterintuitive, then see pipe(8) for more details. In a nutshell, it ensures that a message sent to multiple [valid] recipients will be recieved by everyone in the recipient list, rather than ONLY the first recipient in the list. If you still do not understand, skip step #7 and try sending a message with multiple recipients in the “to”, “cc”, etc fields. Note that only the first recipient in the list will actually receive the message.

[d] For security reasons, SASL authentication is required in order to configure autoresponses via e-mail (You shouldn’t be using unauthenticated SMTP anyway). These instructions assume that SMTP authentication via SASL has already been installed and configured (correctly).

To create an autoresponse message for a user via e-mail:

Send an e-mail to “user+autoresponse@domain.tld” where ‘user’ is the user portion of the e-mail address for the user that you are setting the autoresponse message. The message must originate from “user@domain.tld” (for security reasons) otherwise an autoresponse will not be created. If you have a pre-existing autoresponse message, it will be deleted and the user will be notified via e-mail that the autoresponse message has been disabled. Think of it as a toggle switch. If you do not have a pre-existing autoresponse message, the message you send will now become your autoresponse. You’ll want to format the message exactly as you’d like for it to appear; WYSIWYG (What You Send Is What You Get).

To create an autoresponse message for a user via the shell:

Invoke the following command:

1
autoresponse -e user@domain.tld

Where ‘user@domain.tld’ is the e-mail address of the user who requires an autoresponse. Upon running this command, the vi editor will open; just type the user’s autoresponse, save and quit as you normally would with any text file. That’s all you have to do.

To disable an autoresponse message for a user:

1
autoresponse -d user@domain.tld

To enable an autoresponse message for a user:

1
autoresponse -E user@domain.tld

To delete an autoresponse message for a user:

1
autoresponse -D user@domain.tld

 

 

Trochu jiný přístup za použití databáze http://feurix.org/projects/response/postfix/