WIP: panic on everything since the framework swallows my results
This commit is contained in:
parent
bf818e1a65
commit
4cd2e8216f
25
src/mail.rs
25
src/mail.rs
|
@ -30,39 +30,46 @@ pub fn send_notification(
|
||||||
Goodbye";
|
Goodbye";
|
||||||
} else {
|
} else {
|
||||||
body += &format!(
|
body += &format!(
|
||||||
"<a href=\"{}/unsubscribe?pr={pr_number}&email={}\">Unsubscribe from this PR</a>",
|
"<a href=\"{}/unsubscribe?pr={pr_number}&email={}\">Unsubscribe from this PR</a>\n",
|
||||||
|
&CONFIG.url,
|
||||||
|
encode(recipient)
|
||||||
|
);
|
||||||
|
body += &format!(
|
||||||
|
"<a href=\"{}/unsubscribe?email={}\">Unsubscribe from all PRs</a>",
|
||||||
&CONFIG.url,
|
&CONFIG.url,
|
||||||
encode(recipient)
|
encode(recipient)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let sending_address = env::var("PR_TRACKER_MAIL_ADDRESS")?;
|
let sending_address = env::var("PR_TRACKER_MAIL_ADDRESS").unwrap();
|
||||||
let sending_user = match env::var("PR_TRACKER_MAIL_USER") {
|
let sending_user = match env::var("PR_TRACKER_MAIL_USER") {
|
||||||
Ok(address) => address,
|
Ok(address) => address,
|
||||||
_ => sending_address.clone(),
|
_ => sending_address.clone(),
|
||||||
};
|
};
|
||||||
let sending_passwd = env::var("PR_TRACKER_MAIL_PASSWD")?;
|
let sending_passwd = env::var("PR_TRACKER_MAIL_PASSWD").unwrap();
|
||||||
|
|
||||||
let sending_server = env::var("PR_TRACKER_MAIL_SERVER")?;
|
let sending_server = env::var("PR_TRACKER_MAIL_SERVER").unwrap();
|
||||||
|
|
||||||
let email = Message::builder()
|
let email = Message::builder()
|
||||||
.from(format!("PR-Tracker <{}>", sending_address).parse()?)
|
.from(format!("PR-Tracker <{}>", sending_address).parse().unwrap())
|
||||||
.to(Mailbox::new(None, recipient.parse()?))
|
.to(Mailbox::new(None, recipient.parse().unwrap()))
|
||||||
.subject(format!(
|
.subject(format!(
|
||||||
"PR-tracker: {pr_number}: {pr_title} has reached {:?}",
|
"PR-tracker: {pr_number}: {pr_title} has reached {:?}",
|
||||||
branches
|
branches
|
||||||
))
|
))
|
||||||
.header(ContentType::TEXT_PLAIN)
|
.header(ContentType::TEXT_PLAIN)
|
||||||
.body(body)?;
|
.body(body)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let creds = Credentials::new(sending_user.to_string(), sending_passwd.to_string());
|
let creds = Credentials::new(sending_user.to_string(), sending_passwd.to_string());
|
||||||
|
|
||||||
// Open a remote connection to gmail
|
// Open a remote connection to gmail
|
||||||
let mailer = SmtpTransport::relay(&sending_server)?
|
let mailer = SmtpTransport::relay(&sending_server)
|
||||||
|
.unwrap()
|
||||||
.credentials(creds)
|
.credentials(creds)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Send the email
|
// Send the email
|
||||||
mailer.send(&email)?;
|
mailer.send(&email).unwrap();
|
||||||
|
|
||||||
println!("Email sent successfully!");
|
println!("Email sent successfully!");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue