So I've been using the lettre crate to send email verification codes for account creation: https://crates.io/crates/lettre
This has been working perfectly fine in localhost (sends out emails) however when I try to send an email with my VPS it just times out. I thought it had something to do with the firewall so I enabled port 25 and 2525, but it still times out and doesn't send any emails.
Any ideas?
Thanks in advance.
This is my code:
use lettre_email::Email;
use lettre::smtp::authentication::Credentials;
use lettre::{SmtpClient, Transport};
pub fn mail(address:String, message:String)
{
let creds = Credentials::new
(
"email".to_string(),
"password".to_string(),
);
let mut mailer = SmtpClient::new_simple("smtp.gmail.com")
.unwrap()
.credentials(creds)
.transport();
let email = Email::builder()
.to(address)
.from("email")
.subject("Verification Code")
.text(message)
.build()
.unwrap();
mailer.send(email.into()).ok();
}