Difference between revisions of "Talk:EmailToWiki.pl"

From Organic Design wiki
m (Event driven installation: wrong conditional syntax)
(Change source-code blocks to standard format)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[EmailToWiki.pl]] is called from crontab and has one parameter specifying the name of a configuration file which should reside in the same directory as the script. The config file is <tt>eval</tt>'d and should set the following variables:
 
[[EmailToWiki.pl]] is called from crontab and has one parameter specifying the name of a configuration file which should reside in the same directory as the script. The config file is <tt>eval</tt>'d and should set the following variables:
{{code|<perl>
+
<source lang="perl">
 
# $IP/extensions/EmailToWiki/foo.conf
 
# $IP/extensions/EmailToWiki/foo.conf
 
$popServer      = 'mail.foo.bar';  # this should be empty if running as an Exim4 router
 
$popServer      = 'mail.foo.bar';  # this should be empty if running as an Exim4 router
Line 20: Line 20:
 
$wgSimpleFormsCActionQuery = 'caction';
 
$wgSimpleFormsCActionQuery = 'caction';
 
$wgSimpleFormsSummaryQuery = 'summary';
 
$wgSimpleFormsSummaryQuery = 'summary';
</perl>}}
+
</source>
  
 
== Event driven installation ==
 
== Event driven installation ==
 
The biggest problem with this extension is the inefficient polling of the POP box which makes it unresponsive and consumes unnecessary resources on a regular basis.
 
The biggest problem with this extension is the inefficient polling of the POP box which makes it unresponsive and consumes unnecessary resources on a regular basis.
  
This could be configured in a more event-driven way by integrating with the exim4 router configuration. Specifically the [http://www.exim-new-users.co.uk/content/view/46/1/ queryprogram router] would be used. The program should return '''REDIRECT :blackhole:''' if the message matches any of its rules and is destined for the wiki, or '''PASS''' if not so it can be processed by the next router instead.
+
This could be configured in a more event-driven way by integrating with the exim4 router configuration. Specifically the [http://www.exim-new-users.co.uk/content/view/46/1/ queryprogram router] would be used which executes a given script and passes the message to its STDIN pipe. The program should exit with '''0''' so that no errors are raised and send '''REDIRECT :blackhole:''' to STDOUT if the message matches any of its rules and is destined for the wiki, or '''PASS''' if not so it can be processed by the next router instead.
+
 
 
This would allow the mails to be checked as they come in and if destined for a wiki would be routed there straight away instead of going to the usual mail directory for storage.
 
This would allow the mails to be checked as they come in and if destined for a wiki would be routed there straight away instead of going to the usual mail directory for storage.
  
The router should be placed after the spam router so that we can place a condition in it to only match non-spams which will greatly cut down on the processing.
+
The following router configuration section should be placed after the spam router in ''/var/www/exim4/exim4.conf.template'' because it exhibits a condition specifying to send only non-spams to the ''EmailToWiki.pl'' script which cuts down greatly on the processing required.
 
+
<source>
The router section to add after the ''spam_check'' router in ''/var/www/exim4/exim4.conf.template'' is as follows:
 
{{code|<pre>
 
 
# 860: EmailToWiki router
 
# 860: EmailToWiki router
 
email_to_wiki:
 
email_to_wiki:
Line 39: Line 37:
 
command_user = Debian-exim
 
command_user = Debian-exim
 
condition = "${if !def:h_X-Spam-Flag: {1}{0}}"
 
condition = "${if !def:h_X-Spam-Flag: {1}{0}}"
</pre>}}
+
</source>
 +
*Note: The condition needs to be modified to not process message with no recipient
  
 
== See also ==
 
== See also ==
  
 
*[[Configure mail server]]
 
*[[Configure mail server]]

Latest revision as of 18:11, 22 May 2015

EmailToWiki.pl is called from crontab and has one parameter specifying the name of a configuration file which should reside in the same directory as the script. The config file is eval'd and should set the following variables:

# $IP/extensions/EmailToWiki/foo.conf
$popServer      = 'mail.foo.bar';   # this should be empty if running as an Exim4 router
$popUser        = 'foo';
$popPassword    = '***';
$maxLines       = 100;
$wikiTemplate   = 'Email';
$senders        = 'foo@bar.com';
$filterTo       = false;
$filterFrom     = false;
$deleteSent     = true;
$deleteFiltered = false;
$logFile        = 'foo.log';

# Set these to the same values as the same variable in the wiki
$wgServer = 'http://www.organicdesign.co.nz';
$wgScript = '/wiki/index.php';
$wgSimpleFormsContentQuery = 'content';
$wgSimpleFormsCActionQuery = 'caction';
$wgSimpleFormsSummaryQuery = 'summary';

Event driven installation

The biggest problem with this extension is the inefficient polling of the POP box which makes it unresponsive and consumes unnecessary resources on a regular basis.

This could be configured in a more event-driven way by integrating with the exim4 router configuration. Specifically the queryprogram router would be used which executes a given script and passes the message to its STDIN pipe. The program should exit with 0 so that no errors are raised and send REDIRECT :blackhole: to STDOUT if the message matches any of its rules and is destined for the wiki, or PASS if not so it can be processed by the next router instead.

This would allow the mails to be checked as they come in and if destined for a wiki would be routed there straight away instead of going to the usual mail directory for storage.

The following router configuration section should be placed after the spam router in /var/www/exim4/exim4.conf.template because it exhibits a condition specifying to send only non-spams to the EmailToWiki.pl script which cuts down greatly on the processing required.

# 860: EmailToWiki router
email_to_wiki:
	driver = queryprogram
	command = /var/www/extensions/EmailToWiki/EmailToWiki.pl /var/www/EmailToWiki.conf
	command_user = Debian-exim
	condition = "${if !def:h_X-Spam-Flag: {1}{0}}"
  • Note: The condition needs to be modified to not process message with no recipient

See also