Sign up form and other stuff
This commit is contained in:
parent
b1ffd1a04a
commit
45d4867cb3
18 changed files with 817 additions and 107 deletions
22
backend/src/email.rs
Normal file
22
backend/src/email.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use lettre::{transport::smtp::{authentication::Credentials}, Message, SmtpTransport, Transport};
|
||||
|
||||
///
|
||||
pub fn send_validation(site_url: &str, email: &str, token: &str, smtp_login: &str, smtp_password: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let email = Message::builder()
|
||||
.message_id(None)
|
||||
.from("recipes@gburri.org".parse()?)
|
||||
.to(email.parse()?)
|
||||
.subject("Recipes.gburri.org account validation")
|
||||
.body(format!("Follow this link to confirm your inscription: {}/validation?token={}", site_url, token))?;
|
||||
|
||||
let credentials = Credentials::new(smtp_login.to_string(), smtp_password.to_string());
|
||||
|
||||
let mailer = SmtpTransport::relay("mail.gandi.net")?.credentials(credentials).build();
|
||||
|
||||
if let Err(error) = mailer.send(&email) {
|
||||
println!("Error when sending E-mail:\n{:?}", &error);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue