Expand description
Mailing list manager library.
Data is stored in a sqlite3
database.
You can inspect the schema in SCHEMA
.
Usage
mailpot
can be used with the CLI tool in mailpot-cli
,
and/or in the web interface of the mailpot-web
crate.
You can also directly use this crate as a library.
Example
use mailpot::{models::*, Configuration, Connection, SendMail};
let db = Connection::open_or_create_db(config)?.trusted();
// Create a new mailing list
let list_pk = db
.create_list(MailingList {
pk: 0,
name: "foobar chat".into(),
id: "foo-chat".into(),
address: "foo-chat@example.com".into(),
topics: vec![],
description: None,
archive_url: None,
})?
.pk;
db.set_list_post_policy(PostPolicy {
pk: 0,
list: list_pk,
announce_only: false,
subscription_only: true,
approval_needed: false,
open: false,
custom: false,
})?;
// Drop privileges; we can only process new e-mail and modify subscriptions from now on.
let mut db = db.untrusted();
assert_eq!(db.list_subscriptions(list_pk)?.len(), 0);
assert_eq!(db.list_posts(list_pk, None)?.len(), 0);
// Process a subscription request e-mail
let subscribe_bytes = b"From: Name <user@example.com>
To: <foo-chat+subscribe@example.com>
Subject: subscribe
Date: Thu, 29 Oct 2020 13:58:16 +0000
Message-ID: <1@example.com>
";
let envelope = melib::Envelope::from_bytes(subscribe_bytes, None)?;
db.post(&envelope, subscribe_bytes, /* dry_run */ false)?;
assert_eq!(db.list_subscriptions(list_pk)?.len(), 1);
assert_eq!(db.list_posts(list_pk, None)?.len(), 0);
// Process a post
let post_bytes = b"From: Name <user@example.com>
To: <foo-chat@example.com>
Subject: my first post
Date: Thu, 29 Oct 2020 14:01:09 +0000
Message-ID: <2@example.com>
Hello
";
let envelope = melib::Envelope::from_bytes(post_bytes, None).expect("Could not parse message");
db.post(&envelope, post_bytes, /* dry_run */ false)?;
assert_eq!(db.list_subscriptions(list_pk)?.len(), 1);
assert_eq!(db.list_posts(list_pk, None)?.len(), 1);
Re-exports
pub extern crate anyhow;
pub extern crate chrono;
pub extern crate log;
pub extern crate melib;
pub extern crate rusqlite;
pub extern crate serde;
pub extern crate serde_json;
Modules
- config 🔒
- Mailpot database and methods.
- errors 🔒Errors of this library.
- Filters to pass each mailing list post through. Filters are functions that implement the
PostFilter
trait that can: - How each list handles new posts and new subscriptions.
- Generate configuration for the postfix mail server.
- Processing new posts.
- Queues
- Submit e-mail through SMTP.
- User subscriptions.
- Named templates, for generated e-mail like confirmations, alerts etc.
- Execute operations inside an SQL transaction.
Structs
- Represents a set of characters or bytes in the ASCII range.
- The configuration for the mailpot database and the mail server.
- A connection to a
mailpot
database. - The Error type.
- A
mailto:
value. - A named template.
Enums
- The kind of an error.
- How to send e-mail.
Constants
Traits
- This trait is implemented on all the errors generated by the
error_chain
macro. - Provides the
context
method forResult
. - Additional methods for
Result
, for easy interaction with this crate. - Trait for stripping carets (‘<’,‘>’) from Message IDs.
Functions
- Percent-encode the UTF-8 encoding of the given string.
Type Definitions
- Alias for
chrono::DateTime<chrono::Utc>
. - Convenient wrapper around
std::Result
.