allow sending mails w/o attachments :-)
This commit is contained in:
parent
f7a7ab8733
commit
770e321bed
@ -52,15 +52,17 @@ impl Mail {
|
||||
let content = fs::read(temp_file.path().unwrap()).unwrap();
|
||||
let media_type = format!("{}", temp_file.content_type().unwrap().media_type());
|
||||
let content_type = ContentType::parse(&media_type).unwrap();
|
||||
if let Some(name) = temp_file.name() {
|
||||
let attachment = Attachment::new(format!(
|
||||
"{}.{}",
|
||||
temp_file.name().unwrap(),
|
||||
name,
|
||||
temp_file.content_type().unwrap().extension().unwrap()
|
||||
))
|
||||
.body(content, content_type);
|
||||
|
||||
multipart = multipart.singlepart(attachment);
|
||||
}
|
||||
}
|
||||
|
||||
let email = email.subject(data.subject).multipart(multipart).unwrap();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user