24 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
14c6541dfb
email_server: Drop showing diagnostics/repair and roundcube config
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-01-31 18:46:04 -05:00
Sunil Mohan Adapa
ece2a1db33
email_server: Rename dovecot TLS configuration file for consistency
Tests:

- Configuration parameters are set properly after fresh app setup according to
'doveconf'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-12-14 18:22:57 -05:00
Sunil Mohan Adapa
88e372b8f8
email_server: dovecot: Don't deliver mail to home directory
Delivering mail to home directory is only needed when users are expected to
login via terminal and use command line tools for accessing their email. In
FreedomBox, we expect users to use GUI tools such as Thunderbird and K-9 Mail to
access their mail. So, POP3 and IMAP access sufficient.

Not trying to compatible with command line mail tools means that high
performance mailbox storage formats can be chosen. This is important to ensure
that accessing mail via IMAP is fast. In future, we can consider enabling full
text search using Apache Solr.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-11-03 19:40:47 -04:00
Sunil Mohan Adapa
afc958a884
email_server: dovecot: Authenticate using PAM instead of LDAP
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-11-03 19:40:38 -04:00
Sunil Mohan Adapa
d0cf01fb29
email_server: Don't use user IDs when performing lookups
- Typical mail systems are configured to work on usernames or virtual usernames.
UIDs/GIDs are only needed at the final moment when delivering mails to user
inboxes that need to have proper UID/GID set.

- This makes it easy for dovecot to simply use PAM authentication instead of
having to use LDAP.

- Trying to hide UID from email headers is no longer necessary. Received: header
is important for debugging mail delivery across the chain. Don't miss out.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-11-03 19:40:19 -04:00
Sunil Mohan Adapa
6eb5980f84
email_server: aliases: Minor refactoring to DB schema
- Use the IntergrityError exception instead of a complex query to ignore an
already existing alias.

- When retrieving existing aliases, use explicit list of columns instead of * so
that schema updates adding columns won't fail the code using the row results.

- Use terminology used by post fix. "name" for the name of the alias. "value"
for the mapping.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-10-30 16:15:44 -04:00
Sunil Mohan Adapa
6e8b825d44
email_server: aliases: Drop hash DB and use sqlite3 directly
- Postfix has the ability to use sqlite3 databases directly. There is no need to
synchronize to a hash db and then use that.

- Store the aliases database in /var/lib/postfix/. This will make backup and
restore easier and remove dependence on FreedomBox and its data directory.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-10-30 16:15:26 -04:00
fliu
3ff823e837
email: Sender spoofing patch 1/2: domain rewriting
A sender canonical map deletes the domain part from sender addresses.
Postfix will append @$myhostname after the rewriting.
2021-08-17 19:44:24 -07:00
fliu
1e712f6bc4
email: setup: Configure Roundcube 2021-08-17 19:44:21 -07:00
fliu
5a9c7e5077
email: Documentation, code cleanup
- Audit: finalize MainCfDiagnosis API
- Doc: document Diagnosis models
- Doc: remove hacky imports and replace them with autodoc mock imports
- Views: add `email_` prefix to email server templates
- Apache: delete unnecessary directives (robots tag, cookie header etc.)
2021-08-17 19:44:17 -07:00
fliu
9a98ddadd4
email: postfix: dovecot: Set strong security parameters
Other changes:
- Fix linter error
- Postfix port 25: do not trust localhost IP addresses
2021-08-17 19:44:11 -07:00
fliu
b172b0b1cd
email: Local delivery: use full email address
If the domain part was not provided, $myhostname will be used.
In case $myhostname is not in $mydestinations, the email will be relayed.
In case $myhostname is invalid, the email will be bounced.

The next hop should always be LMTP (local: transport)
and hence the `@localhost`
2021-08-17 19:44:08 -07:00
fliu
27387d4a9c
email: Implement outbound mail filtering
- Make extensive use of the milter protocol
- Milter: add X-Fbx- headers to emails
- All submitted mails go to smtp:localhost:10025 for filtering
- Header privacy for submitted mails
- Rspamd: be able to inject and replace FreedomBox-managed config
- Reserve special addresses for future use

Known issue: internal emails do not go through spam filtering
2021-08-17 19:43:58 -07:00
fliu
85c6b91fbc
email: Code cleanup
- Move render_tabs into plinth.views
- Move admin_tabs and user_tabs into the class
- New interproc module contains inter-process functions
- New helper methods in TabMixin
2021-08-17 19:43:55 -07:00
fliu
e454e8ac1b
email: LMTP: remove the recipient's UID number from email headers 2021-08-17 19:43:52 -07:00
fliu
cdfef82bf6
email: Implement auto-discovery 2021-08-17 19:43:49 -07:00
fliu
355cc84a1b
email: apache: X-Robots-Tag header, full URL match 2021-08-17 19:43:46 -07:00
fliu
c31a896e81
email: Implement spam sorting with sieve
- Sieve script detects spam headers used by Rspamd and SpamAssassin
- Autosubscribe to Archive, Drafts, Junk, Sent, Trash
- Autoexpunge Trash and Junk folders
- INBOX.Junk -> Junk, INBOX.Trash -> Trash, Sent Messages -> Sent
2021-08-17 19:43:42 -07:00
fliu
4375828703
email: Implement alias management
- Separate alias database from system
- Block mail to system users, without backscatter
- Alias management UI for non-admin users
- Enabling/Disabling aliases (mails to /dev/null)

Misc. changes

- Daemon management
- Backup information
- Postconf diagnostics interface
2021-08-17 19:43:23 -07:00
fliu
0acbe5dd6b
email: Support UID number lookup in Dovecot 2021-08-17 19:43:14 -07:00
fliu
7166e63b02
email: Install rspamd; proxy its web interface 2021-08-17 19:42:51 -07:00
fliu
81c9632f5a
email: dovecot: Support user lookup by UID number
Dovecot refuses to open the root user's mail box
Need (!(uidNumber=0)) to correctly return status code
2021-08-17 19:42:45 -07:00
fliu
ba179a860e
email: Set up local delivery (no spam filtering)
Hosts file:

192.168.56.101 host1.test.example virtualbox
10.42.0.101    host2.test.example freedombox

Container setup (run commands in container)

1. Install the email server module
2. Create a FreedomBox account for `fred`
3.
$ sudo postconf myhostname=host2.test.example
$ echo "contactfred: fred" | sudo tee -a /etc/aliases
$ sudo newaliases
$ sudo systemctl reload postfix

Test IMAP (run on host1.test.example)

$ swaks --to=contactfred@host2.test.example --from=spam@host1.test.example
$ mutt -f imaps://fred@host2.test.example

Test mail submission (run in container):

$ swaks --to=spam@host1.test.example --from=contactfred@host2.test.example \
        --server host2.test.example:587 --tlso --auth-user=fred
2021-08-17 19:42:36 -07:00
fliu
aaa6342f93
email: Basic app to manage an email server
- Install postfix and manage the service
- Import ugettext
- Dummy forms and views
- <module>.version (integer) is required

[sunil: Disable the app until remaining issues are worked out]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-08-17 19:42:26 -07:00