MAUTRIX-MAIL
============

A Matrix email bridge. It connects Gmail, iCloud and any custom IMAP/SMTP
server to Matrix.

The bridge polls for new emails and delivers them as Matrix messages. Each
sender domain gets its own room (so bewerbung5@messe-jobs.de and
bewerbung6@messe-jobs.de land in the same messe-jobs.de room). The same
sender always lands in the same room, so you can keep a clean per-contact
inbox inside Matrix.

Replies are sent back via SMTP (attachments included) and saved to the
account's Sent folder via IMAP append.

REQUIREMENTS
------------

- Go 1.26 or newer
- A Matrix homeserver with appservice support (Synapse)
- A database (PostgreSQL recommended)

BUILD
-----

    make build
    make install

The binary is installed to /usr/bin/mautrix-mail.

SETUP
-----

Generate an example config:

    /usr/bin/mautrix-mail --generate-example-config

Edit config.yaml. Under network.accounts you can add as many email accounts
as you like. Each account has a provider of gmail, icloud or custom.

For Gmail use an app password, not the normal account password.
For iCloud use an app-specific password as well.

    network:
        accounts:
          - email: user@gmail.com
            provider: gmail
            password: "app-password"
          - email: user@icloud.com
            provider: icloud
            password: "app-specific-password"
          - email: me@example.com
            provider: custom
            imap_server: mail.example.com
            imap_port: 993
            smtp_server: smtp.example.com
            smtp_port: 587
            password: "password"

Generate the registration file for the homeserver:

    /usr/bin/mautrix-mail --generate-registration

Then add the registration to your Synapse homeserver.yaml under
app_service_config_files and restart Synapse.

LOGIN
-----

Each account in the config acts as its own login. The bridge reads the
account list at startup and connects to every account automatically.

ROOMS
-----

Every distinct sender email address becomes its own direct room. The room is
named after the sender. If that sender writes to you again, the mail lands in
the same room.

To reply, just type in the room. The message is sent via SMTP to that
sender's address.

FILES
-----

Config:   /etc/mautrix-mail/config.yaml
Reg:      /etc/mautrix-mail/registration.yaml
Log:      /var/log/mautrix-mail.log
