Giter Site home page Giter Site logo

perfacilis / goldfish-autoresponder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dirkgroenen/goldfish-autoresponder

0.0 2.0 0.0 24 KB

Goldfish is a simple autoresponder script (written in PHP) for Postfix.

PHP 72.84% Shell 22.27% JavaScript 4.89%

goldfish-autoresponder's Introduction

Goldfish autoresponder

Goldfish is a simple autoresponder script for Postfix. It consists of only one file which can be started through a cronjob. It works with a Postfix, Courier, MySQL and Virtual Users setup. It cannot be used with setups that don't make use of a database to store the mail accounts.

This script is in PHP and BASH available.

There also a plugin for Roundcube available so your users can create their own Auto reply messages.

Installation

To install Goldfish we first have to create a table in our mail database. Open the database and run the following SQL command:

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_disabled` tinyint(4) NOT NULL default '0',
    `subject` varchar(255) NOT NULL default '',
    PRIMARY KEY (`email`),
    FULLTEXT KEY `message` (`message`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Afterwards you download the goldfish.php script and place it in a directory on your server. In my case I'm going for /usr/local/goldfish.

mkdir /usr/local/goldfish
wget https://github.com/dirkgroenen/Goldfish-Autoresponder/archive/master.tar.gz
tar -xvf master.tar.gz -C /usr/local/goldfish
mv /usr/local/goldfish/Goldfish-Autoresponder-master/* /usr/local/goldfish
rm -r /usr/local/goldfish/Goldfish-Autoresponder-master

Configuration

After you have downloaded and extracted the script you have to open it and fill in your database credentials.

PHP

nano /usr/local/goldfish/goldfish.php

In this file you have to change the configuration values so they match with your setup.

$conf['mysql_host'] = "localhost"; // MySQL host
$conf['mysql_user'] = "mailuser"; // MySQL user
$conf['mysql_password'] = "password"; // MySQL password
$conf['mysql_database'] = "mailserver"; // MySQL database where we created the autoresponder table

In some cases you also need to change the MySQL queries to match your mail setup.

After you have configured Goldfish you need to enable it via a cronjob. In my case I want Goldfish to be executed every 5 minutes:

*/5 * * * * /usr/local/goldfish/goldfish.php

BASH

nano /usr/local/goldfish/goldfish.sh

In this file you have to change the configuration values so they match with your setup.

MYSQL_HOST="localhost"
MYSQL_PORT=3306
MYSQL_USER="root"
MYSQL_PASS=""
MYSQL_DATABASE=""

In some cases you also need to change the MySQL queries to match your mail setup.

After configuration you set the execute permissions

chmod a+x /usr/local/goldfish/goldfish.sh

After you have configured Goldfish you need to enable it via a cronjob. In my case I want Goldfish to be executed every 5 minutes:

*/5 * * * * /usr/local/goldfish/goldfish.sh

Creating an autoresponder

After we have installed and configured Goldfish we can create our first Autoresponse message. In this case we are going to do this through mysql so lets login

mysql -u mailuser -p 
USE mailserver;
INSERT INTO `autoresponder` (`email`, `descname`, `from`, `to`, `message`, `enabled`, `force_enabled`, `subject`) VALUES ('[email protected]', '[email protected] Autoresponse', '2015-05-20', '2015-05-30', 'Dear mailer\r\n, I will be out of office till 2015-05-30. Please contact one of my colleagues.\r\nThanks!\r\Henk', 1, 1, 'Out of Office');
quit;

The above command created an autoresposne for [email protected] which will be active from 2015-05-20 till 2015-05-30. Because we have created a cronjob which runs every 5 minutes, Goldfish won't send a message immediately, but somewhere within a range of five minutes after the mail was received.

When opening the /var/log/goldfish it will show something like this:

2015-05-29 12:00:01 Connection to database established successfully
2015-05-29 12:00:01 Database selected successfully
2015-05-29 12:00:01 Successfully updated database (disabled entries)
2015-05-29 12:00:01 Successfully fetched maildir directories
2015-05-29 12:00:01 Reading new emails: new emails found: 1
2015-05-29 12:00:01 Start scanning directory /var/mail/vhosts/mail.com/example/new/
2015-05-29 12:00:01 Found entry [.] in directory /var/mail/vhosts/mail.com/example/new/
2015-05-29 12:00:01 Found entry [..] in directory /var/mail/vhosts/mail.com/example/new/
2015-05-29 12:00:01 Found entry [1432893598.M4690P8298.mail,S=29290,W=29790] in directory /var/mail/vhosts/mail.com/example/new/
2015-05-29 12:00:01 Successfully fetched subject of [email protected]
2015-05-29 12:00:01 Successfully fetched message of [email protected]
2015-05-29 12:00:02 Autoresponse e-mail was sent to: [email protected]

Roundcube plugin

If you want your users to be able to create their own autoresponse you can download and install the Roundcube Goldfish plugin.

The plugin in this repository is compatible with every Roundcube version.

Install

Download this repository and move the autoreply directory (located in roundcube) to your Roundcube plugins directory. Open the Roundcube config file (config/main.inc.php) and add autoreply to the plugin array.

$rcmail_config['plugins'] = array('pluginx', 'autoreply');

Configuration

Open the config.inc.php file and change the database connection string so it matchs your setup.

Credits

Goldfish is originally created by Remo Fritzsche, but not available for download anymore.

goldfish-autoresponder's People

Contributors

dirkgroenen avatar kamuixenom avatar lozik avatar lpiob avatar

Watchers

James Cloos avatar Roy Arisse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.