diff --git a/crates/email/src/mailer.rs b/crates/email/src/mailer.rs index 1671c846..122f891f 100644 --- a/crates/email/src/mailer.rs +++ b/crates/email/src/mailer.rs @@ -90,6 +90,17 @@ impl Mailer { /// # Errors /// /// Will return `Err` if the email failed rendering or failed sending + #[tracing::instrument( + skip_all, + fields( + email.to = %to, + email.from = %self.from, + user.id = %context.user().id, + user_email_verification.id = %context.verification().id, + user_email_verification.code = context.verification().code, + ), + err, + )] pub async fn send_verification_email( &self, to: Mailbox, diff --git a/crates/email/src/transport/mod.rs b/crates/email/src/transport/mod.rs index 33b59e7e..0578934f 100644 --- a/crates/email/src/transport/mod.rs +++ b/crates/email/src/transport/mod.rs @@ -147,7 +147,6 @@ impl AsyncTransport for Transport { match self.inner.as_ref() { TransportInner::Blackhole => { tracing::warn!( - ?envelope, "An email was supposed to be sent but no email backend is configured" ); } diff --git a/crates/templates/src/context.rs b/crates/templates/src/context.rs index 447ad4ee..642a760b 100644 --- a/crates/templates/src/context.rs +++ b/crates/templates/src/context.rs @@ -594,6 +594,18 @@ impl EmailVerificationContext { pub fn new(user: User, verification: UserEmailVerification) -> Self { Self { user, verification } } + + /// Get the user to which this email is being sent + #[must_use] + pub fn user(&self) -> &User { + &self.user + } + + /// Get the verification code being sent + #[must_use] + pub fn verification(&self) -> &UserEmailVerification { + &self.verification + } } impl TemplateContext for EmailVerificationContext {