Saturday, October 12, 2013

Autoresponder for roundcube postfixadmin

Here I will explain configuring autoreply in roundcube.

Create a mysql database table in the mail server database. Here I am using postfixadmin database, so create as metioned below,

mysql -u root
use postfix;

CREATE TABLE `autoresponder` (
`email` varchar(255) NOT NULL default '',
`descname` varchar(255) default NULL,
`from` date NOT NULL default '0000-00-00',
`to` date NOT NULL default '0000-00-00',
`message` text NOT NULL,
`enabled` tinyint(4) NOT NULL default '0',
`force_enabled` tinyint(4) NOT NULL default '0',
`subject` varchar(255) NOT NULL default '',
PRIMARY KEY (`email`),
FULLTEXT KEY `message` (`message`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Grant privileges to the users,
mysql -u root
mysql> GRANT SELECT,INSERT,UPDATE ON postfix.autoresponder TO  autoresponder IDENTIFIED BY 'autoresponder.pass';
mysql> GRANT SELECT ON postfix.mailbox TO autoresponder;
mysql> exit;


Download autoresponder,

autoresponder.zip
unzip autoresponder.zip
cp -a autoresponder.php /usr/bin/

chmod 755 /usr/bin/autoresponder.php

vim /usr/bin/autoresponder.php

/* General */
    $conf['cycle'] = 5 * 60;  <--- Processess mails from maildir accessed within 5 minutes. (set cron 5 minutes)

/* Database information */
$conf['mysql_host'] = "localhost";
$conf['mysql_user'] = "autoresponder";
$conf['mysql_password'] = "autoresponder.pass";
$conf['mysql_database'] = "postfix";

$conf['log_file_path'] = "/tmp/autoresponder.log"

touch log file /tmp/autoresponder.log


Now configure autoreply plugin for roundcube,

cp -a autoreply/ /var/www/roundcube/plugins/
chown apache.apache /var/www/roundcube/plugins/autoreply/ -R

vim config.inc.php
configure database setup.

Enable autoreply plugin in roundcube configuration,

vim /var/www/roundcube/config/main.inc.php
<?php
// Plugins $rcmail_config['plugins'] = array('autoreply');
?>

apache2ctl restart

In Roundcube enable autoresponse in preferences and run autoresponder.php ,

php /usr/bin/autoresponder.php

cron settings ..

*/5 * * * * /usr/bin/autoresponder.php

No comments:

Post a Comment