ISP mail provider manager with mysql and integrated LDAP server. https://rainbox.email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
5.0 KiB

  1. # Rainbox Email
  2. Rainbox Email is an ISP-like mail service database manager. It also comes with some built-in authentication provider features such as an integrated LDAP server.
  3. For now, it only supports MySQL.
  4. Please feel free to contribute by making issues, bug reports and pull requests.
  5. ## /!\ THIS PROJECT STILL LACKS ESSENTIAL FEATURES SUCH AS: /!\
  6. - [x] ~~Change password~~
  7. - [ ] Password reset (a magic link to remove your password, see [this issue](https://eternae.ink/arisu/swaf/issues/23))
  8. - [ ] Quota management
  9. - [ ] Editable terms of service
  10. - [ ] Complex permissions system
  11. - [ ] Redirections (can be manually setup with sql queries)
  12. - Probably many others, please make an issue so I can add them to this list
  13. ## How does it work?
  14. When a user register, they don't immediately get a mailbox. If approval_mode is on, then they have to get approved by an administrator. Then they have to create their first email address which will be their mailbox username.
  15. Users can only create one email address with their username from public domains (domains set as owned by "Public").
  16. However, domains can also be owned by a specific user in which case the user owning the domain can create infinite addresses @the-domain.com.
  17. Note that a user only has one mailbox once they create their first address and cannot have more.
  18. ## Installation instructions & recommendations
  19. ### Requirements
  20. - mariadb (for the mysql database that will be operated)
  21. - redis (session, cache)
  22. - A working mail smtp server (to send emails)
  23. - git and yarn for updates
  24. ### Instructions
  25. - Create a user i.e. `rainbox-email` and its home directory i.e. `/home/rainbox-email`
  26. - `su rainbox-email` (switch to the new user)
  27. - `git clone git@gitlab.com:ArisuOngaku/rainbox.email.git ~/live` (clone Rainbox Email into a new `live` folder)
  28. - `cd ~/live`
  29. - `yarn install && yarn build`
  30. - MySQL
  31. - Create a new empty database named as per configuration (default is `rainbox_email`)
  32. - Create a new mysql user and give them all permissions on the database (`GRANT ALL PRIVILEGES ON rainbox_email.* TO rainbox_email@localhost IDENTIFIED BY "secret_password";`)
  33. - Don't forget to add mysql user and password in `config/local.json5` (see ###Configuration)
  34. - Configure mail (required) and redis (if needed)
  35. - For a private instance, please don't forget to set `approval_mode` to `true`
  36. - Service
  37. - Edit [app.service](app.service) as needed, copy to `/etc/systemd/system/rainbox-email.service`
  38. - When ready, enable and start the service (`systemctl enable --now rainbox-email`)
  39. - Once started, if there were no errors then the database should be created.
  40. - To gain administrator rights, register an account and then go back to mysql and run: `UPDATE users SET is_admin=1 WHERE name="your_user_name";`
  41. ### Configuration
  42. Create a `config/local.json5` file and override all wanted parameters. See `config/{default,prouction}.json5` and `node_modules/swaf/config/{default,production}.json5` for defaults.
  43. ## Postfix and dovecot mysql queries
  44. ### Postfix
  45. - `virtual_mailbox_domains` => `SELECT 1 FROM mail_domains WHERE name='%s'`
  46. - `virtual_mailbox_maps` => `SELECT 1 FROM users u LEFT JOIN mail_identities i ON i.user_id=u.id AND u.main_mail_identity_id=i.id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE CONCAT(i.name, '@', d.name)='%s'`
  47. - `virtual_alias_maps` => `(SELECT redirects_to FROM mail_identities i LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE CONCAT(i.name, '@', d.name)='%s' AND redirects_to IS NOT NULL) UNION (SELECT CONCAT(i.name, '@', d.name) FROM users u LEFT JOIN mail_identities i ON i.id=u.main_mail_identity_id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE (SELECT u.id FROM users u LEFT JOIN mail_identities i ON i.user_id=u.id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE CONCAT(i.name, '@', d.name)='%s' AND redirects_to IS NULL LIMIT 1)=u.id AND i.id IS NOT NULL)`
  48. - `smtpd_sender_login_maps` => `SELECT CONCAT(i.name, '@', d.name) FROM users u LEFT JOIN mail_identities i ON i.user_id=u.id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE CONCAT(i.name, '@', d.name)='%s'`
  49. ### Dovecot `dovecot-sql.conf.ext`
  50. Note that the quota is hardcoded in the `user_query` to 5GB, please change as needed.
  51. - `user_query = SELECT CONCAT(i.name, '@', d.name) as user, CONCAT('*:bytes=', '5368709000') as quota_rule, '/storage1/mail/%d/%n' as home, 1011 as uid, 1012 as gid FROM users u LEFT JOIN mail_identities i ON i.user_id=u.id AND u.main_mail_identity_id=i.id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE CONCAT(i.name, '@', d.name)='%u'`
  52. - `password_query = SELECT password FROM users u LEFT JOIN mail_identities i ON i.user_id=u.id AND u.main_mail_identity_id=i.id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE CONCAT(i.name, '@', d.name)='%u' AND redirects_to IS NULL`
  53. - `iterate_query = SELECT CONCAT(i.name, '@', d.name) as user FROM users u LEFT JOIN mail_identities i ON i.id=u.main_mail_identity_id LEFT JOIN mail_domains d ON i.mail_domain_id=d.id WHERE i.id IS NOT NULL`
  54. It is recommended to set `default_pass_scheme = ARGON2ID`.