I am not very good in rust, using version 1.32.0 of rustc and cargo to control a heating system, which works very fine.
Now I try to integrate a simple smtp function, to get information about bad system states via mail. I tried "lettre" from version 0.4 to 10.0 , but all the time I get many errors "use of unstable library feature" concerning "'split_ascii_whitespace', 'try_from', 'alloc', 'maybe_uninit' ...". "lettre" ends in "Could not compile cc
". With "mail-smtp" I had similar problems. Is there any solution for this, how can I work with an older version of rustc and cargo, which I need for my control software, without crashing by using new crates?
I used the folllowing code from https://github.com/lettre/lettre#readme:
Cargo.toml:
[dependencies]
lettre = "0.10.0-beta.3" # here I tried also "0.9" down to "0.4"
main.rs:
extern crate lettre;
fn main() {
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};
let email = Message::builder()
.from("NoBody <nobody@domain.tld>".parse().unwrap())
.reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
.to("Hei <hei@domain.tld>".parse().unwrap())
.subject("Happy new year")
.body(String::from("Be happy!"))
.unwrap();
let creds = Credentials::new("smtp_username".to_string(), "smtp_password".to_string());
// Open a remote connection to gmail
let mailer = SmtpTransport::relay("smtp.gmail.com")
.unwrap()
.credentials(creds)
.build();
// Send the email
match mailer.send(&email) {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {:?}", e),
}
}