Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ impl Emails {
}
}

fn build_message<E: Email>(&self, recipient: &str, email: E) -> Result<Message, EmailError> {
fn build_message(
&self,
recipient: &str,
subject: String,
body: String,
) -> Result<Message, EmailError> {
// The message ID is normally generated by the SMTP server, but if we let it generate the
// ID there will be no way for the crates.io application to know the ID of the message it
// just sent, as it's not included in the SMTP response.
Expand All @@ -100,9 +105,6 @@ impl Emails {

let from = Mailbox::new(Some(self.domain.clone()), self.from.clone());

let subject = email.subject();
let body = email.body();

let message = Message::builder()
.message_id(Some(message_id.clone()))
.to(recipient.parse()?)
Expand All @@ -115,7 +117,7 @@ impl Emails {
}

pub async fn send<E: Email>(&self, recipient: &str, email: E) -> Result<(), EmailError> {
let email = self.build_message(recipient, email)?;
let email = self.build_message(recipient, email.subject(), email.body())?;

self.backend
.send(email)
Expand Down