rustfmt email.rs
This commit is contained in:
parent
62d12e314c
commit
a454914b1f
11
src/email.rs
11
src/email.rs
|
@ -66,7 +66,8 @@ pub struct SimpleEmail {
|
|||
|
||||
impl SimpleEmail {
|
||||
pub fn new(base: Email, from: &str, to: &str, in_reply_to: Option<String>) -> Self {
|
||||
let recipients = to.split('\n').map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).collect();
|
||||
let recipients =
|
||||
to.split('\n').map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).collect();
|
||||
Self { base: base.clone(), from: from.to_string(), to: recipients, in_reply_to }
|
||||
}
|
||||
pub fn send_email(&self, subject: String, body: String) -> Result<String, Box<dyn Error>> {
|
||||
|
@ -88,14 +89,14 @@ impl Email {
|
|||
}
|
||||
|
||||
pub fn send_email(
|
||||
&self, from: String, to: &[String], subject: String, body: String, in_reply_to: Option<String>,
|
||||
&self, from: String, to: &[String], subject: String, body: String,
|
||||
in_reply_to: Option<String>,
|
||||
) -> Result<String, Box<dyn Error>> {
|
||||
let message_id = Uuid::new_v4().to_string() + &self.message_id_suffix;
|
||||
let mut email = Message::builder()
|
||||
.from(from.parse().unwrap());
|
||||
let mut email = Message::builder().from(from.parse().unwrap());
|
||||
for recipient in to {
|
||||
email = email.to(recipient.parse().unwrap());
|
||||
};
|
||||
}
|
||||
email = email.message_id(Some(message_id.clone()));
|
||||
let email =
|
||||
if in_reply_to.is_some() { email.in_reply_to(in_reply_to.unwrap()) } else { email }
|
||||
|
|
Loading…
Reference in a new issue