This commit is contained in:
Paolo Barbolini
2025-05-02 05:35:54 +02:00
parent 81b233def4
commit abc8cdf789
2 changed files with 5 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ use lettre::{
message::header::ContentType, message::header::ContentType,
transport::smtp::{ transport::smtp::{
authentication::Credentials, authentication::Credentials,
client::{Certificate, Tls, TlsParameters}, client::{tls, Tls},
}, },
Message, SmtpTransport, Transport, Message, SmtpTransport, Transport,
}; };
@@ -23,10 +23,10 @@ fn main() {
// Use a custom certificate stored on disk to securely verify the server's certificate // Use a custom certificate stored on disk to securely verify the server's certificate
let pem_cert = fs::read("certificate.pem").unwrap(); let pem_cert = fs::read("certificate.pem").unwrap();
let cert = Certificate::from_pem(&pem_cert).unwrap(); let cert = tls::native_tls::Certificate::from_pem(&pem_cert).unwrap();
let tls = TlsParameters::builder("smtp.server.com".to_owned()) let tls = tls::TlsParametersBuilder::<tls::NativeTls>::new("smtp.server.com".to_owned())
.add_root_certificate(cert) .add_root_certificate(cert)
.build() .build_legacy()
.unwrap(); .unwrap();
let creds = Credentials::new("smtp_username".to_owned(), "smtp_password".to_owned()); let creds = Credentials::new("smtp_username".to_owned(), "smtp_password".to_owned());

View File

@@ -23,7 +23,7 @@ pub struct TlsParametersBuilder<B: TlsBackend> {
} }
impl<B: TlsBackend> TlsParametersBuilder<B> { impl<B: TlsBackend> TlsParametersBuilder<B> {
pub(super) fn new(domain: String) -> Self { pub fn new(domain: String) -> Self {
Self { Self {
domain, domain,
cert_store: Default::default(), cert_store: Default::default(),