Skip to content

Commit

Permalink
Add cc args to mailer.
Browse files Browse the repository at this point in the history
  • Loading branch information
BWStearns committed Jun 4, 2024
1 parent 9d4d7c4 commit cf277a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mailer/email_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?);
}
Expand Down Expand Up @@ -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());

Expand Down
4 changes: 4 additions & 0 deletions src/mailer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Args {
pub reply_to: Option<String>,
pub locals: serde_json::Value,
pub bcc: Option<String>,
pub cc: Option<String>,
}

/// The structure representing an email details.
Expand All @@ -44,6 +45,8 @@ pub struct Email {
pub html: String,
/// BCC header to message
pub bcc: Option<String>,
/// CC header to message
pub cc: Option<String>,
}

/// The options struct for configuring the email sender.
Expand Down Expand Up @@ -95,6 +98,7 @@ pub trait Mailer {
text: content.text,
html: content.html,
bcc: args.bcc.clone(),
cc: args.cc.clone(),
},
)
.await
Expand Down

0 comments on commit cf277a5

Please sign in to comment.