autoreply

-----

Postfixadmin 3.2 autoreply out of office on Redhat / Centos 7

yum -y install perl-Email-Valid perl-Email-Sender perl-Email-Simple perl-Test-Email perl-Try-Tiny perl-MIME-Charset perl-MIME-EncWords perl-Log-Log4perl perl-Log-Dispatch perl-Test-mysqld perl-Mail-Sendmail

groupadd -r -g 65501 vacation

useradd -r -u 65501 -g vacation -d /var/spool/vacation -s /sbin/nologin vacation

mkdir /var/spool/vacation

cd /var/www/postfixadmin/VIRTUAL_VACATION

cp vacation.pl /var/spool/vacation/vacation.pl

chown -R vacation:vacation /var/spool/vacation

chmod -R 700 /var/spool/vacation

chmod 750 /var/spool/vacation/vacation.pl

#  touch  /var/log/vacation.log /var/log/vacation-debug.log

#  chown  vacation:vacation /var/log/vacation*

# vi /var/spool/vacation/vacation.pl

our $db_type = ‘mysql’;

our $db_username = ‘postfixadmin’;

our $db_password = ‘yourdbpasswd’;

our $db_name = ‘postfixadmin’;

our $vacation_domain = ‘autoreply.yourdomain.com’;

# Set to 1 to enable logging to syslog.

our $syslog = 1;

vi /var/www/html/postfixadmin/config.inc.php

$CONF[‘vacation’] = ‘YES’;

$CONF[‘vacation_domain’] = ‘autoreply.yourdomain.com’;

systemctl restart httpd

# vi /etc/postfix/master.cf

vacation unix – n n – – pipe

flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} — ${recipient}

# vi /etc/postfix/main.cf

transport_maps = hash:/etc/postfix/transport

vacation_destination_recipient_limit = 1    # if not or on

# vi /etc/postfix/transport

autoreply.yourdomain.com  vacation

postmap /etc/postfix/mastaer.cf

postmap /etc/postfix/main.cf

postmap /etc/postfix/transport

systemctl restart postfix

                     -----------------------

vacation function so that the reply every day you have to make adjustment in two files.

vi /var/www/html/postfixadmin/config.inc.php

// 0 => only reply to the first mail while on vacation

// 1 => reply on every mail

$CONF['vacation_choice_of_reply'] = array (

   0 => 'reply_once',        // Sends only Once the message during Out of Office

   # considered annoying - only send a reply on every mail if you really need it

   # 1 => 'reply_every_mail',       // Reply on every email

   60*60 *24*7 => 'reply_once_per_week'        // Reply if last autoreply was at least a week ago

);

$PALANG['reply_once'] = 'Reply once';

$PALANG['reply_every_mail'] = 'Reply on every mail';

$PALANG['reply_once_per_day'] = 'Reply once a day';

$PALANG['reply_once_per_week'] = 'Reply once a week';

        ------------------------------------x--------------------------------------------------

# vi /var/www/html/postfixadmin/config.inc.php

/ Vacation Control

// If you want users to take control of vacation set this to 'YES'.

$CONF['vacation_control'] ='YES';

// Vacation Control for admins

// Set to 'YES' if your domain admins should be able to edit user vacation.

$CONF['vacation_control_admin'] = 'YES';

// Alllow ReplyType Control

// This varible will be check in ./templates/vacation.tpl if it should enable this option

// YES mains it show the reply option everthing els mains it will not show

$CONF['replytype_control'] = 'YES';

// AllowUser Reply

// You can Allow or Disable User to contole over Reply Type

// This varible will be check in ./templates/vacation.tpl if it should enable this option

// YES mains it show the reply option everthing els mains it will not show

$CONF['allow_user_reply'] = 'YES';

// RepleyType options

// If you want to define additional reply options put them in array below.

$CONF['choice_of_reply'] = array (

'One Reply', // Sends only Once the message during Out of Office

'Auto Reply', // Reply on every email but not within autoreplydelay

'Interval Reply' // Reply on every email but not within repldelay_default

);

// ReplyType default

// You should define default replytype. It must be in array above.

$CONF['replytype_default'] = 'One Reply';

// autoreplydelay

// You should define autodefaultdelay is seconds

// if a new message comes in within this delay it most likely that that the sender is

// autoreplying on our autoreply message.

$CONF['autoreplydelay_default'] = '100';

// Replydelay default

// You should define default replydelay time here time in in seconds.

$CONF['intervaldelay_default'] = '86400'; // is 1 day = 60 sec * 60 min * 24 hours

PostfixAdmin Vacation/Out of Office Autoresponder

PostfixAdmin actually comes with a perl plugin that enables a Vacation/Out of Office Autoresponder; for some reason, though, it’s not installed by default. The setup only takes a few minutes and it enables users to manage their own autoresponders, so it’s well worth the time.

This setup assumes that you’ve followed this Postfix Dovecot Mailserver Walkthrough. If not, your mileage may vary. Basically, you’ll need to have PostfixAdmin setup, and be using it to manage virtual mail users.

First, we need to grab some perl library dependancies

view sourceprint?

1.sudo apt-get install libmail-sender-perl libdbd-mysql-perl libemail-valid-perl libmime-perl liblog-log4perl-perl liblog-dispatch-perl libgetopt-argvfile-perl libmime-charset-perl libmime-encwords-perl

Create a user to manage the system:

view sourceprint?

1. groupadd -r -g 65501 vacation

2. useradd-r -u 65501 -g vacation -d /var/spool/vacation -s /sbin/nologin vacation

3. mkdir/var/spool/vacation

view sourceprint?

1.cd/var/www/postfixadmin/VIRTUAL_VACATION

2. cpvacation.pl /var/spool/vacation/vacation.pl

3. chown-R vacation:vacation /var/spool/vacation

4. chmod-R 700 /var/spool/vacation

Update the vacation script with your settings

view sourceprint?

1. vi /var/spool/vacation/vacation.pl

our $db_type = ‘mysql’;

our $db_username = ‘postfix’;

our $db_password = ‘yourdbpasswd’;

our $db_name = ‘postfix’;

our $vacation_domain = ‘autoreply.yourdomain.com’;

Save and close (CTRL + X)

Update the postfixadmin config file

view sourceprint?

1.cd/var/www/postfixadmin

2.sudonano config.inc.php

$CONF['vacation'] = ‘YES’;

$CONF['vacation_domain'] = ‘autoreply.yourdomain.com’;

view sourceprint?

1.cd/etc/postfix

2. vi master.cf

Add (near the end of the file):

vacation unix – n n – - pipe flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} ${recipient}

Save and close (CTRL + X)

view sourceprint?

1. vi main.cf

transport_maps = hash:/etc/postfix/transport

Save and close (CTRL + X)

Create (or update) a transport map to handle the redirected email

view sourceprint?

1. vi transport

autoreply.yourdomain.com vacation

Save and close (CTRL + X)

Postfix uses a hashed file to do the lookups, the postmap command creates that file.

view sourceprint?

1. postmap /etc/postfix/transport

Reload the postfix config to activate the changes

view sourceprint?

1.  /etc/init.d/postfix reload

That’s it. Now if you log in to your postfix admin control panel, you’ll be able to manage autoresponders for all the accounts. When users log in to their specific accounts they’ll also be able to manage their own out of office notifications.


             -------------X--------------------




groupadd -r -g 65501 vacationuseradd -r -u 65501 -g vacation -d /var/spool/vacation -s /sbin/nologin vacation

mkdir /var/spool/vacation
cd /var/www/html/postfixadmin/VIRTUAL_VACATIONcp vacation.pl /var/spool/vacation/vacation.plchown -R vacation:vacation /var/spool/vacationsudo chmod -R 700 /var/spool/vacation
# vi /var/spool/vacation/vacation.pl
our $db_type = ‘mysql’;our $db_username = ‘postfix’;our $db_password = ‘yourdbpasswd’;our $db_name = ‘postfix’;
our $vacation_domain = ‘autoreply.yourdomain.com’;
cd /var/www/postfixadmin# vi config.inc.php
$CONF[‘vacation’] = ‘YES’;$CONF[‘vacation_domain’] = ‘autoreply.yourdomain.com’;

cd /etc/postfix# vi master.cf
Add (near the end of the file):
vacation unix n n pipe     flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} — ${recipient}

# vi main.cf
transport_maps = hash:/etc/postfix/transport
# vi transport
autoreply.yourdomain.com vacation


postmap /etc/postfix/transport/etc/init.d/postfix reload


















-------