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 = [ 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()), })