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";
|
||||
} else {
|
||||
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,
|
||||
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") {
|
||||
Ok(address) => address,
|
||||
_ => 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()
|
||||
.from(format!("PR-Tracker <{}>", sending_address).parse()?)
|
||||
.to(Mailbox::new(None, recipient.parse()?))
|
||||
.from(format!("PR-Tracker <{}>", sending_address).parse().unwrap())
|
||||
.to(Mailbox::new(None, recipient.parse().unwrap()))
|
||||
.subject(format!(
|
||||
"PR-tracker: {pr_number}: {pr_title} has reached {:?}",
|
||||
branches
|
||||
))
|
||||
.header(ContentType::TEXT_PLAIN)
|
||||
.body(body)?;
|
||||
.body(body)
|
||||
.unwrap();
|
||||
|
||||
let creds = Credentials::new(sending_user.to_string(), sending_passwd.to_string());
|
||||
|
||||
// Open a remote connection to gmail
|
||||
let mailer = SmtpTransport::relay(&sending_server)?
|
||||
let mailer = SmtpTransport::relay(&sending_server)
|
||||
.unwrap()
|
||||
.credentials(creds)
|
||||
.build();
|
||||
|
||||
// Send the email
|
||||
mailer.send(&email)?;
|
||||
mailer.send(&email).unwrap();
|
||||
|
||||
println!("Email sent successfully!");
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue