工作中~
分类:
2008-07-22 13:50:30
You should have a setup which consists of postfix with mysql support. goldfish gets his information about Mailboxes and autoresponders out of a MySQL Database, so make sure that all these information are stored in your database. The following information should be provided from the database for each mailbox entry:
goldfish needs to have his own mysql database table, for more information take a look at the installation section of this document. It suites perfectly to the tutorial of Christof Haas . In other words it is made for this tutorial.
This installation manual assumes that you have a running PHP and PHP CLI on your server.
Create a mysql database table in the mailserver database with the following code:
照搬这个表便可。
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',
`subject` varchar(255) NOT NULL default '',
PRIMARY KEY (`email`),
FULLTEXT KEY `message` (`message`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Now I recommend you to create a new mysql user who has only readable access to this table. For unix based systems you can follow this example:
mysql -u root -p (your password)
mysql> GRANT SELECT ON `mailserver`.`autoresponder` TO `goldfish` IDENTIFIED BY 'myPassword';
mysql> exit;
Get the of goldfish and extract it to a directory in your server. Important is the file autoresponder.php in the archive. Since the database password will be stored in this file, make sure that it isn't readable for anyone.
//通过官网下载goldfish-002.tar.gz,解压后将goldfish-002.php改为autoresponder.php,不改也没啥关系。
I suggest you to create a system user for goldfish and place the file in it's home directory, for example:
/home/goldfish/autoresponder.php
Unfortunately, the configuration of goldfish isn't yet very comfortable. Open the source and take a look at the first lines respective the configuration section:
goldfish has to know in which cycle you want to run it respective in which cycle the cron job runs. Please specify the cycle in seconds.
/* General */
$conf['cycle'] = 1 * 60;//在此设置时间
goldfish can write a log for you, but this is optional. If you want goldfish to write a log for you, set write_log to true and specify the path of the log file, otherwise leave the path parameter empty and set write_log to false.
/* Logging */
$conf['log_file_path'] = "/var/log/goldfish";
$conf['write_log'] = true;
Since goldfish connects to the database we created just now, you have to specify the database parameters:
/* Database information */
$conf['mysql_host'] = "localhost";
$conf['mysql_user'] = "goldfish";
$conf['mysql_password'] = "myPassword";
$conf['mysql_database'] = "mailserver";
No we are at the most complex part of the configuration. To make goldfish as flexible as possible, I decided to let the user have controll over the SQL queries. For the following steps you have to know SQL (MySQL) a little bit. You have to place some placeholders, for example %m.
This query has to return the path (`path`) of the corresponding maildir-Mailbox with the email-address %m:
$conf['q_mailbox_path'] = "SELECT concat('/home/vmail/', SUBSTRING_INDEX(email,'@',-1), '/', SUBSTRING_INDEX(email,'@',1), '/') as `path` FROM view_users WHERE `email` = '%m'";
This query has to return the following fields from the autoresponder table: `from`, `to`, `email`, `message` where `enabled` = 2:
$conf['q_forwardings'] = "SELECT * FROM `autoresponder` WHERE `enabled` = 1";
This query has to disable every autoresponder entry which ended in the past:
$conf['q_disable_forwarding'] = "UPDATE `autoresponder` SET `enabled` = 0 WHERE `to` < CURDATE();";
This query has to activate every autoresponder entry which starts today:
$conf['q_enable_forwarding'] = "UPDATE `autoresponder` SET `enabled` = 1 WHERE `from` = CURDATE();";
This query has to return the message of an autoresponder entry identified by email %m:
$conf['q_messages'] = "SELECT `message` FROM `autoresponder` WHERE `email` = '%m'";
This query has to return the subject of the autoresponder entry identified by email %m:
$conf['q_subject'] = "SELECT `subject` FROM `autoresponder` WHERE `email` = '%m'";
goldfish has to run continous and in a specific interval. At every run, goldfish checks for new mails in the corresponding mailboxes and sends an answer, if wanted.
To run goldfish in an interval, I recommend you to create a cronjob. There are several possibilities to make a cronjob. Maybe the simplest one is to add (for example) the following line to the file /etc/crontab/:
#crontab -e
*/1 * * * * vmail /home/goldfish/autoresponder.php
This will make goldfish run every five minutes. In this example, the goldfish runs under the user vmail which is the owner of autoresponder.php as well as of all the maildir mails.
----------------------------------------------
Update manual for patch 1 //安装补丁
执行后台文件:
#php -f /home/goldfish/autoresponder.php
php -f /usr/share/squirrelmail/src/autoreply1.php
To configure autoresponders for specific email addresses, simply insert a record into the goldfish table. I think the fields are really self explained.
This tiny little squirrelmail extension by Paolo Cassago allows you to set goldfish autoresponders directly in squirrelmail. This Plugin has been tested with squirrelmail 1.4.7 and is released under the GNU/GPL.
echo " \n";
displayInternalLink ('src/autoreply.php', "Auto reply");
---------------------------------------------------------------------
|
|
|