Skip to content

Commit

Permalink
Item456: work in progress
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/MailInContrib@1323 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Dec 13, 2008
1 parent b4bd4ad commit 118ef48
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 173 deletions.
44 changes: 19 additions & 25 deletions data/TWiki/MailInContrib.txt → data/System/MailInContrib.txt
@@ -1,7 +1,7 @@
---+!! <nop>MailInContrib for TWiki
---+!! <nop>Mail In to Foswiki
%SHORTDESCRIPTION%
<a href="http://wikiring.com"><img src="%ATTACHURL%/logo.gif" style="float:right" /></a>
This Contrib supports the submission of content to TWiki topics via e-mail.
This Contrib supports the submission of content to Foswiki topics via e-mail.

<!--

Expand All @@ -10,14 +10,12 @@ This Contrib supports the submission of content to TWiki topics via e-mail.
It is automatically generated from the subversion repository, and any changes
you make will simply be overwritten the next time a release is generated.

Instead, you could check your fix in, raise a bug in the Bugs web, or mail the author.
Instead, you could check your fix in, raise a bug in the Tasks web, or mail the author.
-->

<div class="twikiBroadcastMessage" style="background-color:#ffc;">WARNING: TWiki-4 only. If you want to use this extension with an earlier version of TWiki, please use [[http://twiki.org/cgi-bin/attach/Plugins/%TOPIC%?filename=%TOPIC%.zip&revInfo=1][revision 7 of the zip]].</div>
Mails can be pulled out of mail folders using [[CPAN:Email::Folder::POP3][POP3]], [[CPAN:Email::Folder::IMAP][IMAP]], or anything else supported by CPAN:Email::Folder.

Mails for twiki can be pulled out of mail folders using [[CPAN:Email::Folder::POP3][POP3]], [[CPAN:Email::Folder::IMAP][IMAP]], or anything else supported by CPAN:Email::Folder.

The implementation is very simple; a script called =mailincron= is run every so often (usually by =cron= or an equivalent offline job scheduler). The script trawls the mail folders you specify and grabs messages that it recognises as being for the TWiki.
The implementation is very simple; a script called =mailincron= is run every so often (usually by =cron= or an equivalent offline job scheduler). The script trawls the mail folders you specify and grabs messages that it recognises as being for the wiki.

For example, your wayward child might send a mail like this from an internet cafe in Thailand:
<verbatim>
Expand All @@ -27,7 +25,7 @@ Subject: Travels.DailyDiary: cashless

*Phuket*: I've run out of money!
</verbatim>
The message lands in your email folder at your ISP. Once an hour, a cron job runs the =mailincron= script, which scans the folder. If it finds any messages that have nothing but a correctly formatted TWiki Web.Topic<nop>Name in the subject line, that topic is appended to (created) with the plain text of the email. The Web must exist, though the topic will be created if necessary. Both web and topic _must_ be specified.
The message lands in your email folder at your ISP. Once an hour, a cron job runs the =mailincron= script, which scans the folder. If it finds any messages that have nothing but a correctly formatted Web.Topic<nop>Name in the subject line, that topic is appended to (created) with the plain text of the email. The Web must exist, though the topic will be created if necessary. Both web and topic _must_ be specified.

In our example, the web exists, and so does the topic, so the following text gets appended to Travels.Daily<nop>Diary:
<div style='background: #EEFFEE'>
Expand All @@ -37,7 +35,7 @@ In our example, the web exists, and so does the topic, so the following text get
<em> -- Prodigal Son &lt;gapper@isp.co.uk> 10 Jul 2005 08:35:11 -0900 </em>

</div>
Attachments to the mail get treated as attachments by TWiki, and attached to the target topic.
Attachments to the mail get treated as attachments by Foswiki, and attached to the target topic.

Note that =mailincron= will only process messages that have arrived since the last time it ran. So if there was an error adding a mail, it won't attempt to add it again even if it is still in the inbox.

Expand All @@ -50,53 +48,51 @@ You can also define a 'spambox' for each mail folder. A spambox is a topic that

The module can use special HTML comments in the topic to decide where to insert new emails within the text.

If it sees the comment =&lt;!--MAIL--&gt;= it will insert the incoming mail immediately *below* the comment. =MAIL= is rather ike a TWikiVariable; you can give it parameters. For example, =&lt;!--MAIL{where="below"}--&gt;=. The following options are available:
If it sees the comment =&lt;!--MAIL--&gt;= it will insert the incoming mail immediately *below* the comment. =MAIL= is rather ike a [[%SYSTEMWEB%.Macro][Foswiki macro]]; you can give it parameters. For example, =&lt;!--MAIL{where="below"}--&gt;=. The following options are available:
* =where= - can be =above=, =below= (relative to the comment) =top=, =bottom= (of the topic)
* =template= set to the name of one of the templates in %SYSTEMWEB%.MailInContribTemplate to change the formatting of comments. The default format is "below" format.

If there is no such comment in the topic, then it just appends it to the end. If there is more than one, only the first is recognised.

Any attachments in the mail get added to the target topic as TWiki attachments. Attachments are also listed immediately below the mail body in the topic.
Any attachments in the mail get added to the target topic as attachments. Attachments are also listed immediately below the mail body in the topic.

---+ How the contributor is identified
The user identity is used for access control checks on the target topic, so you can use TWiki access controls to protect target topics.
The user identity is used for access control checks on the target topic, so you can use Foswiki access controls to protect target topics.

You can configure the module to look at the =From:= entry in the email, and if a registered user has set that email (see ChangeEmailAddress), then they are identified as the contributor. Note that there is a security risk here, as the =From:= address in e-mail can easily be spoofed.

You can also optionally set a default user for an inbox, so if the user can't be identified from the mail, it will fall back to the default.

<!--
* Set SHORTDESCRIPTION = Supports submissions to TWiki via e-mail
* Set SHORTDESCRIPTION = Supports submissions to Foswiki via e-mail
-->

---++ Installation
%$INSTALL_INSTRUCTIONS%

__Note__: The CPAN =Email= modules uses *many* pluggable modules to support different folder types. It's impossible to cover all the options here; all we can suggest is that you try running the script from the command-line and resolve missing modules as you find them.
* Set up cron (or equivalent) jobs to run =mailincron=. You must =cd= to the TWiki bin directory, and invoke the sript from there (this is so =mailincron= can read =setlib.cfg=)
* Set up cron (or equivalent) jobs to run =mailincron=. You must =cd= to the =bin= directory, and invoke the sript from there (this is so =mailincron= can read =setlib.cfg=)

Because of the security issues involved (passwords for the mailboxes etc.) configuration uses variables set in your =LocalSite.cfg=. The easiest way to set them is using =configure=.

The =mailincron= script takes one optional parameter, <tt>debug</tt>, which takes a boolean value e.g. <tt>debug=1</tt>. If you pass anything other than 0 or the empty string in =debug=, the script will scan the mail folders, describe what it would have done, and exit, without modifying any folders, the TWiki, or sending any mails.
The =mailincron= script takes one optional parameter, <tt>debug</tt>, which takes a boolean value e.g. <tt>debug=1</tt>. If you pass anything other than 0 or the empty string in =debug=, the script will scan the mail folders, describe what it would have done, and exit, without modifying any folders, the wiki, or sending any mails.

To run the script you need to set up a cron job. For example, to transfer mail into the TWiki once every hour you might write:
To run the script you need to set up a cron job. For example, to transfer mail into the wiki once every hour you might write:
<verbatim>
0 * * * * cd /home/twiki/bin && ../tools/mailincron 2&>1 >> /home/twiki/logs/mailincron.log
0 * * * * cd /home/twiki/bin && ../tools/mailincron 2>&1 >> /home/twiki/logs/mailincron.log
</verbatim>
You _must_ run the script from the bin directory.
Make sure that the cron is run by a user with the permissions needed to read and write the TWiki data directory.

This is a brand-new development, not related in any to the original Foswiki:Extensions/MailInAddon. Due acknowledgement is made to those early pioneers for the idea. ;-)
Make sure that the cron is run by a user with the permissions needed to read and write the =data= directory.

---++ Contrib Info

Another great TWiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!
Another great Foswiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!

Many thanks to the following sponsors for supporting this work:
* [[http://www.evolvedmedianetwork.com][Evolved Media Network]]

| Author: | TWiki:Main/CrawfordCurrie (http://c-dot.co.uk) |
| Copyright &copy;: | 2005, TWiki Contributors |
| Author: | Foswiki:Main.CrawfordCurrie (http://c-dot.co.uk) |
| Copyright &copy;: | 2005, TWiki Contributors; 2008 Foswiki Contributors |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Dependencies: | %$DEPENDENCIES% |
| Version: | %$VERSION% |
Expand All @@ -118,8 +114,6 @@ Many thanks to the following sponsors for supporting this work:
| 31 July 2005 | 1.001 Back-ported to Cairo, added spambox (work generously supported by the [[http://www.evolvedmedianetwork.com/][Evolved Media Network]]) |
| 10 Mar 2005 | 1.000 Initial version |
| Home: | Foswiki:Extensions/%TOPIC% |
| Feedback: | Foswiki:Extensions/%TOPIC%Dev |
| Appraisal: | http://foswiki.org/Extensions/%TOPIC%Appraisal |

__Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences

Expand Down
File renamed without changes.

0 comments on commit 118ef48

Please sign in to comment.