From 9d4d7c4066d2dd100becbf293e81264cbd730253 Mon Sep 17 00:00:00 2001 From: Brian Stearns Date: Mon, 3 Jun 2024 23:05:40 -0400 Subject: [PATCH 1/2] Add BCC field to the mailers. --- src/mailer/email_sender.rs | 5 +++++ src/mailer/mod.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/mailer/email_sender.rs b/src/mailer/email_sender.rs index 51af6434e..17c1fb3a5 100644 --- a/src/mailer/email_sender.rs +++ b/src/mailer/email_sender.rs @@ -105,6 +105,10 @@ impl EmailSender { ) .to(email.to.parse()?); + if let Some(bcc) = &email.bcc { + builder = builder.bcc(bcc.parse()?); + } + if let Some(reply_to) = &email.reply_to { builder = builder.reply_to(reply_to.parse()?); } @@ -160,6 +164,7 @@ mod tests { subject: "Email Subject".to_string(), text: "Welcome".to_string(), html: html.to_string(), + bcc: None, }; assert!(sender.mail(&data).await.is_ok()); diff --git a/src/mailer/mod.rs b/src/mailer/mod.rs index a0bdb9555..6c6f7302c 100644 --- a/src/mailer/mod.rs +++ b/src/mailer/mod.rs @@ -24,6 +24,7 @@ pub struct Args { pub to: String, pub reply_to: Option, pub locals: serde_json::Value, + pub bcc: Option, } /// The structure representing an email details. @@ -41,6 +42,8 @@ pub struct Email { pub text: String, /// HTML template pub html: String, + /// BCC header to message + pub bcc: Option, } /// The options struct for configuring the email sender. @@ -91,6 +94,7 @@ pub trait Mailer { subject: content.subject, text: content.text, html: content.html, + bcc: args.bcc.clone(), }, ) .await From cf277a51cc772e9c9c3bf30e4c8a139bfafcc8c3 Mon Sep 17 00:00:00 2001 From: Brian Stearns Date: Tue, 4 Jun 2024 19:17:27 -0400 Subject: [PATCH 2/2] Add cc args to mailer. --- src/mailer/email_sender.rs | 5 +++++ src/mailer/mod.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/mailer/email_sender.rs b/src/mailer/email_sender.rs index 17c1fb3a5..ba2da15c5 100644 --- a/src/mailer/email_sender.rs +++ b/src/mailer/email_sender.rs @@ -109,6 +109,10 @@ impl EmailSender { builder = builder.bcc(bcc.parse()?); } + if let Some(cc) = &email.cc { + builder = builder.cc(cc.parse()?); + } + if let Some(reply_to) = &email.reply_to { builder = builder.reply_to(reply_to.parse()?); } @@ -165,6 +169,7 @@ mod tests { text: "Welcome".to_string(), html: html.to_string(), bcc: None, + cc: None, }; assert!(sender.mail(&data).await.is_ok()); diff --git a/src/mailer/mod.rs b/src/mailer/mod.rs index 6c6f7302c..ab2244652 100644 --- a/src/mailer/mod.rs +++ b/src/mailer/mod.rs @@ -25,6 +25,7 @@ pub struct Args { pub reply_to: Option, pub locals: serde_json::Value, pub bcc: Option, + pub cc: Option, } /// The structure representing an email details. @@ -44,6 +45,8 @@ pub struct Email { pub html: String, /// BCC header to message pub bcc: Option, + /// CC header to message + pub cc: Option, } /// The options struct for configuring the email sender. @@ -95,6 +98,7 @@ pub trait Mailer { text: content.text, html: content.html, bcc: args.bcc.clone(), + cc: args.cc.clone(), }, ) .await