gs.group.messages.add.mbox2gs
Documentation¶
Authors: | Marek Kuziel; Michael JasonSmith; |
---|---|
Contact: | Michael JasonSmith <mpj17@onlinegroups.net> |
Date: | 2015-03-24 |
Organization: | GroupServer.org |
Copyright: | This document is licensed under a Creative Commons Attribution-Share Alike 4.0 International License by OnlineGroups.Net. |
This product provides mbox2gs script, which allows to import
email messages from mbox
archives to GroupServer. It can be
used for migration of mailing-list archives ie. to migrate
mailing-lists from Mailman to GroupServer.
Contents:
How to import mbox
files into GroupServer¶
The following describes all steps before mbox2gs can be called. This document is intended for advanced users only. Only attempt to use this if you are really sure you know what you are doing! You have been warned.
(Optional) Disable SMTP (sending emails) in your GroupServer instance. You can disable SMTP in one of two ways.
Modify
etc/gsconfig.ini
in your GroupServer installation- In
etc/gsconfig.ini
you have sections[config-default]
, which has setsmtp = on
by default. Setsmtp = off
. - Stop and start again your instance so the configuration change takes effect.
- Test sending of email via your GroupServer instance. No message should be sent.
- In
Re-configure your GroupServer instance to use Python’s native SMTP daemon running in debug mode:
SMPT port set to 2525 in
config.cfg
Run Buildlout:
$ buildout -N
Start the server:
$ sudo python -m smtpd -n -c DebuggingServer localhost:2525
Test sending of email via your GroupServer instance. No message should be sent, but you should see the email in the DebuggingServer that you are running.
Important: You may want to disable SMTP in your GroupServer instance while you are testing, or even migrating archivesd from old Mailman mailing-lists, because every email you import would be send to your mailing list members. Which is something you may wish to avoid.
Prepare Mailman archives for migration.
Long story short, things are not in ideal shape in any Mailman archive out there, because:
- Email addresses are usually obfuscated (eg. some.email at example.com, some.email).
- A typical Mailman archive (usually gzipped) is often an invalid mbox file.
The
mailman2mbox
Python script deals with the issues and helps you to convert your Mailman archives to mbox format <https://gist.github.com/corydolphin/1728592>.Create a new GroupServer group to which you intend to import mbox archive(s) in to.
Example:
http://groups.example.com/groups/my-group/
Get a list of all email addresses from your Mailman mailing-list, or extract the list from mbox archives.
Load all email addresses to the group via the Add members in bulk page, linked from the Admin section of the group.
Note: Unless you disable SMTP everyone on the list will get an email about the fact that you added them to the group. All prepared. You are now ready to migrate your
mbox
archive(s) using mbox2gs (see mbox2gs).
mbox2gs¶
Description¶
Usually, an advanced user of Groupserver calls mbox2gs when required to add email messages from mbox archive to a GroupServer group.
Optional Arguments¶
-
-h
,
--help
¶
Show a help message and exit.
-
-v
,
--verbose
¶
Turn on verbose output (default is quiet: no news is good news).
-
-l
<LISTID>
,
--list
<LISTID>
¶ The list to send the message to. By default it is extracted from the x-original-to header.
-
-f
<FILE>
,
--file
<FILE>
¶ The name of the file that contains the mbox archive. Only one archive can be imported at the time. If omitted (or
-
) standard-input will be read.
-
-c
<CONFIG>
,
--config
<CONFIG>
¶ The name of the GroupServer configuration file (default
INSTANCE_HOME/etc/gsconfig.ini
) that contains the token that will be used to authenticate the script when it tries to add the email to the site. (See Configuration file for more information.)
-
-i
<INSTANCE>
,
--instance
<INSTANCE>
¶ The identifier of the GroupServer instance configuration to use (default
default
).
Returns¶
The script returns 0
on success, or a non-zero on an
error. In the case of an error, mbox2gs follows the
convention specified in /usr/include/sysexits.h
. In
addition the error message that is written to stderr
starts
with the enhanced mail system status code (RFC 3463). See
smtp2gs for more information.
Examples¶
Import the mbox archive stored in /tmp/test.mbox
into the
group my_group
that is on the site groups.example.com
,
and produce verbose output:
$ mbox2gs -v -l my_group -f /tmp/test.mbox http://groups.example.com
Configuration file¶
The configuration for the mbox2gs
script is handled by the
gs.config
module [1]. It is entirely concerned with
token authentication [2]. To authenticate script needs to
pass a token to the web pages that are used to add a post
[3]. The pages compare the token that was passed in to one
that is stored in the database. If they match the script is
allowed to post.
Examples¶
Below is the configuration of the token for the GroupServer instance
default
:
[webservice-default]
token = theValueOfTheToken
A more complex system, which has separate testing
and production
environments:
[config-testing]
...
webservice = testing
[config-production]
...
webservice = production
[webservice-testing]
token = theValueOfTheTokenForTesting
[webservice-production]
token = theValueOfTheTokenForProduction
The token-configuration for two separate sites (accessed through different URLs) that are supported by the same database:
[config-firstSite]
...
webservice = default
[config-secondSite]
...
webservice = default
[webservice-default]
token = theValueOfTheDefaultToken
[1] | See gs.config
<https://github.com/groupserver/gs.config> |
[2] | See gs.auth.token
<https://github.com/groupserver/gs.auth.token> |
[3] | See gs.group.messages.add.base
<https://github.com/groupserver/gs.group.messages.add.base> |
The code¶
The mbox2gs
script is provided by the module
gs.group.messages.add.mbox2gs.script
. The main
function
takes the name of the default configuration file a single
argument, which is normally supplied by buildout
when it
generates the mbox2gs
script from the entry point.
The script parses the command-line arguments, and calls two further functions:
gs.group.messages.add.smtp2gs.servercomms.get_group_info_from_address
:
The script posts to the page/gs-group-messages-add-group-exists.html
to check if the group exists, and to get some information about the group.
gs.group.messages.add.smtp2gs.servercomms.add_post
:
The script posts to the page/gs-group-messages-add-email.html
to actually add the post.
Both pages are provided by the gs.group.messages.add.base
module [1]; the data is sent by the
gs.form.post_multipart
function [2], with
gs.auth.token
[3] providing authentication (see the
section Configuration File below).
[1] | See gs.group.messages.add.base
<https://github.com/groupserver/gs.group.messages.add.base> |
[2] | See gs.form
<https://github.com/groupserver/gs.form> |
[3] | See gs.auth.token
<https://github.com/groupserver/gs.auth.token> |
Changelog¶
2.1.3 (2015-12-11)¶
- Fixing the unit-tests so they work with zc.recipe.testrunner
2.1.2 (2015-11-10)¶
- Fixing the link to the
mailman2mbox
script, thanks to Alexander Köplinger
2.1.1 (2015-05-12)¶
- Fixing the
man
page documentation
2.1.0 (2015-03-24)¶
- Following the changes to the relay-address prefix in gs.group.messages.add.smtp2gs
- Moving all the documentation to the
docs
folder, and rendering them on Read The Docs - Naming all the ReStructuredText files as such
- Switching to GitHub as the primary code repository
2.0.0 (2014-05-05)¶
- Adding a verbose flag
- Using gs.group.messages.add.smtp2gs as a module
- Adding a smoke-test with Tox
1.0.1 (2014-02-06)¶
- Switching to Unicode literals
- Updating the product metadata
1.0.0 (2013-03-28)¶
Initial version, cloned off
gs.group.messages.add.smtp2gs. Prior to the creation of this
product there was some mbox
importing code in
Products.XWFMailingListManager
.
Resources¶
- Code repository: https://github.com/groupserver/gs.group.messages.add.mbox2gs
- Documentation http://groupserver.readthedocs.io/projects/gsgroupmessagesaddmbox2gs/
- Questions and comments to http://groupserver.org/groups/development
- Report bugs at https://redmine.iopen.net/projects/groupserver