From f7f82ccd90662cdd3b6c57d9faf476a5a20a9775 Mon Sep 17 00:00:00 2001 From: Tommy McCormick Date: Fri, 6 Dec 2024 15:24:53 -0500 Subject: [PATCH 1/2] chore(deps): use rustls with reqwest rather than openssl --- Cargo.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5c1fc6e2b..0ee1de140 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,13 @@ backtrace_printer = { version = "1.3.0" } # cli clap = { version = "4.4.7", features = ["derive"], optional = true } colored = "2" -reqwest = { version = "0.12.7", features = ["json"] } +reqwest = { version = "0.12.7", features = [ + "charset", + "http2", + "json", + "macos-system-configuration", + "rustls-tls", +], default-features = false } sea-orm = { version = "1.1.0", features = [ From 1737be8fc63dab8be9f7f9b54732442b59750a4d Mon Sep 17 00:00:00 2001 From: Tommy McCormick <16668493+mccormickt@users.noreply.github.com> Date: Sun, 8 Dec 2024 01:41:23 -0500 Subject: [PATCH 2/2] feat(mailer): expose hello_name for SMTP client config (#1057) * feat(mailer): expose hello_name for SMTP client config * chore: add commented out config for mailer hello name to template --- loco-new/base_template/config/development.yaml.t | 12 +++++++----- src/config.rs | 2 ++ src/mailer/email_sender.rs | 9 +++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/loco-new/base_template/config/development.yaml.t b/loco-new/base_template/config/development.yaml.t index cd1bf250d..259657ae2 100644 --- a/loco-new/base_template/config/development.yaml.t +++ b/loco-new/base_template/config/development.yaml.t @@ -22,8 +22,8 @@ server: host: http://localhost # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block middlewares: - {%- if settings.asset %} - {%- if settings.asset.kind == "server" %} + {%- if settings.asset %} + {%- if settings.asset.kind == "server" %} static: enable: true must_exist: true @@ -32,7 +32,7 @@ server: uri: "/static" path: "assets/static" fallback: "assets/static/404.html" - {%- elif settings.asset.kind == "client" %} + {%- elif settings.asset.kind == "client" %} static: enable: true must_exist: true @@ -42,9 +42,9 @@ server: path: "frontend/dist" fallback: "frontend/dist/index.html" {%- endif -%} - + {%- endif -%} - + {%- if settings.background%} # Worker Configuration @@ -83,6 +83,8 @@ mailer: # auth: # user: # password: + # Override the SMTP hello name (default is the machine's hostname) + # hello_name: {%- endif %} # Initializers Configuration diff --git a/src/config.rs b/src/config.rs index 31eeccb1a..340159230 100644 --- a/src/config.rs +++ b/src/config.rs @@ -500,6 +500,8 @@ pub struct SmtpMailer { pub secure: bool, /// Auth SMTP server pub auth: Option, + /// Optional EHLO client ID instead of hostname + pub hello_name: Option, } /// Authentication details for the mailer diff --git a/src/mailer/email_sender.rs b/src/mailer/email_sender.rs index e392365b5..3cb2b86ca 100644 --- a/src/mailer/email_sender.rs +++ b/src/mailer/email_sender.rs @@ -3,8 +3,9 @@ //! sending emails with options like sender, recipient, subject, and content. use lettre::{ - message::MultiPart, transport::smtp::authentication::Credentials, AsyncTransport, Message, - Tokio1Executor, Transport, + message::MultiPart, + transport::smtp::{authentication::Credentials, extension::ClientId}, + AsyncTransport, Message, Tokio1Executor, Transport, }; use tracing::error; @@ -60,6 +61,10 @@ impl EmailSender { .credentials(Credentials::new(auth.user.clone(), auth.password.clone())); } + if let Some(hello_name) = config.hello_name.as_ref() { + email_builder = email_builder.hello_name(ClientId::Domain(hello_name.clone())); + } + Ok(Self { transport: EmailTransport::Smtp(email_builder.build()), })