Version 0.2.0 #2
1 changed files with 10 additions and 7 deletions
17
src/main.rs
17
src/main.rs
|
@ -80,11 +80,13 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut mailer = SendmailTransport::new();
|
let mut mailer = SendmailTransport::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match rx.recv() {
|
match rx.recv() {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
println!("Sending mail to: {}", data[0]);
|
println!("Sending mail to: {}", data[0]);
|
||||||
|
let title = format!("You were mentioned in {} on {}", data[2], data[1]);
|
||||||
|
let body = format!("{} wrote: {}", data[3], data[4]).into_bytes();
|
||||||
let mail = lettre::SendableEmail::new(
|
let mail = lettre::SendableEmail::new(
|
||||||
lettre::Envelope::new(
|
lettre::Envelope::new(
|
||||||
Some(
|
Some(
|
||||||
|
@ -94,13 +96,14 @@ fn main() {
|
||||||
vec![
|
vec![
|
||||||
lettre::EmailAddress::new(data[0].clone()).unwrap()]
|
lettre::EmailAddress::new(data[0].clone()).unwrap()]
|
||||||
).unwrap(),
|
).unwrap(),
|
||||||
format!("You were mentioned in {} on {}", data[2], data[1]),
|
title,
|
||||||
format!("{}: {}", data[3], data[4]).into_bytes()
|
body
|
||||||
);
|
);
|
||||||
match mailer.send(mail) {
|
|
||||||
Ok(_) => println!("Email sent successfully!"),
|
match mailer.send(mail) {
|
||||||
Err(e) => panic!("Could not send email: {:?}", e),
|
Ok(_) => println!("Email sent successfully!"),
|
||||||
}
|
Err(e) => panic!("Could not send email: {:?}", e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(_e) => (),
|
Err(_e) => (),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue