Chinaunix首页 | 论坛 | 博客
  • 博客访问: 595401
  • 博文数量: 142
  • 博客积分: 10016
  • 博客等级: 上将
  • 技术积分: 1835
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-10 14:30
个人简介

工作中~

文章分类

全部博文(142)

文章存档

2009年(25)

2008年(117)

我的朋友

分类:

2008-07-22 13:50:30


以下为goldfish软件包的后台安装过程:

Requirements  安装要求

Required packages 必需软件包

  • MySQL-Server ()
  • POSTFIX installation ()
  • PHP5+ cli (command line interface, )

Configuration requirements

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:

  • Path to (maildir!) mailbox
  • Email adress

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.

Installation

This installation manual assumes that you have a running PHP and PHP CLI on your server.

Database Setup

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;

Copy the file

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

Configuration

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:

Cycle

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;//在此设置时间

Logging

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;

Database information

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";

Query configuration

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'";

Cronjob

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 //安装补丁

  • Execute, if you are a *nix based system:
  • patch /home/goldfish/autoresponder.php patch-002-p1.diff

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

执行后台文件:

#php -f /home/goldfish/autoresponder.php

php -f /usr/share/squirrelmail/src/autoreply1.php

Add autoresponders 执行前台

To configure autoresponders for specific email addresses, simply insert a record into the goldfish table. I think the fields are really self explained.

goldfish for squirrelmail

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.

Installation instructions
  • Download the  of gfs (goldfish for squirrelmail) gfs-001.phps  文件,并将其改为autoreply.php
  • Rename it to autoreply.php and copy it under the src folder of your squirrelmail installation.
  • Under the functions folder of squirrelmail, add the following lines into the function displayPageHeader() of page_header.php:

    echo "  \n";
    displayInternalLink ('src/autoreply.php', "Auto reply");

  • Configure the database connection on autoreply.php, changing the
    connection values at lines: 22,23,24 and 25 in autoreply.php.
  • Now log into the squirrelmail. The autoreply.php will enable the autoresponder of the user connected to squirrelmail.
  • 在 autoreply.php文件中,有时需修改 $sqlstr = "insert into autoresponder values ('" . $username . "', NULL,'" . $df . "','" . $de . "','" .
        str_replace("'","''",$_POST['message']) . "'," . $_POST['enabled'] . ", '" . str_replace("'","''",$_POST['subject']) . "')";
  • 原文件中,此句缺失一个 NULL

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

文件: autoreply.rar
大小: 1KB
下载: 下载
文件: autoresponder.rar
大小: 2KB
下载: 下载
文件: goldfish.rar
大小: 52KB
下载: 下载
阅读(1308) | 评论(0) | 转发(0) |
0

上一篇:Dovecot Sieve plugin

下一篇:postfix 多域名支持

给主人留下些什么吧!~~