diff --git a/apps/docs/src/content/docs/contributing/labrinth.md b/apps/docs/src/content/docs/contributing/labrinth.md index db80ae67..02c50b0f 100644 --- a/apps/docs/src/content/docs/contributing/labrinth.md +++ b/apps/docs/src/content/docs/contributing/labrinth.md @@ -5,7 +5,7 @@ description: Guide for contributing to Modrinth's backend This project is part of our [monorepo](https://github.com/modrinth/code). You can find it in the `apps/labrinth` directory. The instructions below assume that you have switched your working directory to the `apps/labrinth` subdirectory. -[labrinth] is the Rust-based backend serving Modrinth's API with the help of the [Actix](https://actix.rs) framework. To get started with a labrinth instance, install docker, docker-compose (which comes with Docker), and [Rust]. The initial startup can be done simply with the command `docker-compose up`, or with `docker compose up` (Compose V2 and later). That will deploy a PostgreSQL database on port 5432 and a MeiliSearch instance on port 7700. To run the API itself, you'll need to use the `cargo run` command, this will deploy the API on port 8000. +[labrinth] is the Rust-based backend serving Modrinth's API with the help of the [Actix](https://actix.rs) framework. To get started with a labrinth instance, install docker, docker-compose (which comes with Docker), and [Rust]. The initial startup can be done simply with the command `docker-compose up`, or with `docker compose up` (Compose V2 and later). That will deploy a PostgreSQL database on port 5432, a MeiliSearch instance on port 7700, and a [Mailpit](https://mailpit.axllent.org/) SMTP server on port 1025, with a web UI to inspect sent emails on port 8025. To run the API itself, you'll need to use the `cargo run` command, this will deploy the API on port 8000. To get a basic configuration, copy the `.env.local` file to `.env`. Now, you'll have to install the sqlx CLI, which can be done with cargo: diff --git a/apps/labrinth/.env.local b/apps/labrinth/.env.local index 09b6e719..aa07fa20 100644 --- a/apps/labrinth/.env.local +++ b/apps/labrinth/.env.local @@ -87,11 +87,11 @@ HCAPTCHA_SECRET=none SMTP_FROM_NAME=Modrinth SMTP_FROM_ADDRESS=no-reply@mail.modrinth.com -SMTP_USERNAME=none -SMTP_PASSWORD=none -SMTP_HOST=none -SMTP_PORT=465 -SMTP_TLS=tls +SMTP_USERNAME= +SMTP_PASSWORD= +SMTP_HOST=localhost +SMTP_PORT=1025 +SMTP_TLS=none SITE_VERIFY_EMAIL_PATH=auth/verify-email SITE_RESET_PASSWORD_PATH=auth/reset-password diff --git a/apps/labrinth/src/auth/email/mod.rs b/apps/labrinth/src/auth/email/mod.rs index 2220f389..914a7427 100644 --- a/apps/labrinth/src/auth/email/mod.rs +++ b/apps/labrinth/src/auth/email/mod.rs @@ -39,7 +39,8 @@ pub fn send_email_raw( let password = dotenvy::var("SMTP_PASSWORD")?; let host = dotenvy::var("SMTP_HOST")?; let port = dotenvy::var("SMTP_PORT")?.parse::().unwrap_or(465); - let creds = Credentials::new(username, password); + let creds = + (!username.is_empty()).then(|| Credentials::new(username, password)); let tls_setting = match dotenvy::var("SMTP_TLS")?.as_str() { "none" => Tls::None, "opportunistic_start_tls" => { @@ -55,13 +56,12 @@ pub fn send_email_raw( } }; - let mailer = SmtpTransport::relay(&host)? - .port(port) - .tls(tls_setting) - .credentials(creds) - .build(); + let mut mailer = SmtpTransport::relay(&host)?.port(port).tls(tls_setting); + if let Some(creds) = creds { + mailer = mailer.credentials(creds); + } - mailer.send(&email)?; + mailer.build().send(&email)?; Ok(()) } diff --git a/docker-compose.yml b/docker-compose.yml index c1401115..955e6586 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,6 +58,19 @@ services: interval: 3s timeout: 5s retries: 3 + mail: + image: axllent/mailpit:v1.27 + container_name: labrinth-mail + ports: + - '1025:1025' + - '8025:8025' + environment: + MP_ENABLE_SPAMASSASSIN: postmark + healthcheck: + test: ['CMD', 'wget', '-q', '-O/dev/null', 'http://localhost:8025/api/v1/info'] + interval: 3s + timeout: 5s + retries: 3 labrinth: profiles: - with-labrinth