gs.group.messages.add.smtp2gs
Documentation¶
This product allows email messages, coming in on SMTP, to be added to a GroupServer group.
Contents:
smtp2gs¶
Synopsis¶
Description¶
smtp2gs to adds an email message to a GroupServer group. It is usually called by an SMTP server (such as postfix).
Optional Arguments¶
-
-h
,
--help
¶
Show a help message and exit
-
-m
<MAXSIZE>
,
--max-size
<MAXSIZE>
¶ The maximum size of the post that will be accepted, in mebibytes (default 200MiB).
-
-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 message. If omitted (or
-
) standard-input will be read.
-
-t
{server,message}
,
--time-source
{server,message}
¶ Where to get the time that the message was written. Using
server
(the default) avoids issues caused by the clocks of the group members being incorrect. Usingmessage
will extract the post-time from the Date header.
-
-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.
-
-i
<INSTANCE>
,
--instance
<INSTANCE>
¶ The identifier of the GroupServer instance configuration to use (default
default
).
Returns¶
smtp2gs returns 0
on success, or a non-zero value
on an error (following 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. These include transient errors
and permanent errors.
Transient Errors¶
Any errors that can be solved by changing the configuration
(either of postfix or the Configuration file) are marked as
transient (with a 4.x.x
status code).
Code | Note | Fix |
---|---|---|
4.3.5 | Error with the configuration file. | Correct the Configuration file. |
4.4.4 | Error connecting to URL. | Check that the server is running, or alter the URL that is used to call smtp2gs. |
4.4.5 | The system is too busy. | Wait. |
4.5.0 | Could not decode the data returned by the server. | Usually this is caused by an invalid token in the Configuration file. Fix the token in the file. |
4.5.2 | No host in the URL. | Alter the URL that is used in the call to smtp2gs so it has a host-name. |
Permanent Errors¶
The five permanent errors are listed below.
Code | Note |
---|---|
5.1.1 | There is no such group to send the message to. |
5.1.3 | No x-original-to header in the email message. |
5.3.0 | The file containing the email was empty. |
5.3.4 | Email message too large. |
5.5.0 | Error communicating with the server (either while looking up the group information or adding the message). |
Examples¶
Adding a post to a group in the general case, where the email is read of standard input:
$ smtp2gs http://groups.example.com
Over-riding the x-original-to header. This allows posts to an old email address to be sent to a new group.
$ smtp2gs --list newGroupId http://groups.example.com
Testing, by reading a file from /tmp
$ smtp2gs --file /tmp/test.mbox http://groups.example.com
Setting the maximum size of messages posted to a group to 1MiB
$ smtp2gs --max-size 1 http://groups.example.com
Using the time-stamp in the message, rather than the current time on the server.
$ smtp2gs --time-source message http://groups.example.com
Using the token for a specific GroupServer instance called
production
$ smtp2gs --instance production http://groups.example.com
Configuration file¶
The configuration for the smtp2gs
script is handled by the
gs.config
module [3]. 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
[1]. 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.group.messages.add.base
<https://github.com/groupserver/gs.group.messages.add.base> |
[2] | See gs.auth.token
<https://github.com/groupserver/gs.auth.token> |
[3] | See gs.config
<https://github.com/groupserver/gs.config> |
gs.group.messages.add.smtp2gs
Internals¶
The gs.group.messages.add.smtp2gs
does not have a public
API, other than what is provided by the script itself. However,
the internals are documented below.
The script¶
The smtp2gs
script is provided by the module
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 smtp2gs
script
from the entry point.
The script parses the command-line arguments, and calls two further functions:
servercomms.get_group_info_from_address()
:- This calls the page
/gs-group-messages-add-group-exists.html
to check if the group exists, and to get some information about the group. servercomms.add_post()
:- This calls the page
/gs-group-messages-add-email.html
to actually add the post.
Both pages are provided by the gs.group.messages.add.base
product [1]; the data is sent by the
gs.form.post_multipart
function [2], with
gs.auth.token
[3] providing authentication (see
Configuration file).
Exit values¶
XVERP¶
Locking¶
Server communications¶
[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¶
3.0.5 (2015-12-11)¶
- Fixing two unit tests
3.0.4 (2015-08-17)¶
- Updating to the
man
page and product metadata
3.0.3 (2015-05-12)¶
- Fixing the
man
page documentation
3.0.2 (2015-03-31)¶
- Avoiding the relay code if the list-identifier is specified, thanks to Piers
- Adding more unit tests
3.0.1 (2015-03-18)¶
- Dropping gs.profile.email.relay from the product dependencies: it does rely on it, but for the page rather than for the code
3.0.0 (2015-03-17)¶
- Relaying on email messages to group members, closing Feature 4106
2.1.3 (2015-02-12)¶
- Adding the documentation to Read the Docs
2.1.2 (2014-10-24)¶
- Switching to GitHub as the primary code repository, naming the reStructuredText files as such.
2.1.1 (2014-06-18)¶
- Fixing a race-condition, with thanks to Iris.
2.1.0 (2014-05-05)¶
- Added Python 3 support.
- Added unit tests.
- Handle the absence of an
x-original-to
header if the list identifier is provided.
2.0.2 (2014-04-09)¶
- Fixing an error with the arguments to the script.
2.0.1 (2014-02-06)¶
- Switching to Unicode literals.
2.0.0 (2013-08-27)¶
- Added SSL handling, thanks to Tom.
- Updating the product metadata.
1.0.1 (2012-11-30)¶
- PEP-8 and Python 2.6 cleanup
1.0.0 (2012-08-01)¶
- Initial version, based on a script in
XWFMailingListManager
.