From 645e773d3ea81b2929b504ae81e09f20ef04361e Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 17 Jan 2020 01:36:52 +0300 Subject: [PATCH] Construct list of recipients in SendMdn There is always one recipient for MDNs, so it is easier to only handle this case. --- src/job.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/job.rs b/src/job.rs index cfdbcf0e5..4d1c374ef 100644 --- a/src/job.rs +++ b/src/job.rs @@ -282,20 +282,10 @@ impl Job { let rendered_msg = job_try!(mimefactory.render()); let body = rendered_msg.message; - // XXX: there is probably only one recipient as this is an MDN. - let recipients = rendered_msg - .recipients - .iter() - .filter_map( - |addr| match async_smtp::EmailAddress::new(addr.to_string()) { - Ok(addr) => Some(addr), - Err(err) => { - warn!(context, "invalid recipient: {} {:?}", addr, err); - None - } - }, - ) - .collect::>(); + let addr = contact.get_addr(); + let recipient = job_try!(async_smtp::EmailAddress::new(addr.to_string()) + .map_err(|err| format_err!("invalid recipient: {} {:?}", addr, err))); + let recipients = vec![recipient]; /* connect to SMTP server, if not yet done */ if !context.smtp.lock().unwrap().is_connected() {