Dependencies
= { = "<version>" }
Configuration items
[]
= "smtp.gmail.com" # SMTP mail server address,
= 465 # SMTP server port number
= true # Enable TLS
= { = "user@gmail.com", = "passwd" } # Authentication information
= false # Whether to test mail server connection on startup
Components
After configuring the above configuration items, the plugin will automatically register a MailerSTMP asynchronous client. This object is an alias of lettre::AsyncSmtpTransport<Tokio1Executor>.
pub type Mailer = AsyncSmtpTransport;
Extract the Component registered by the plugin
The MailPlugin plugin automatically registers an SMTP client for us. We can use Component to extract this connection pool from AppState. Component is an axum extractor.
async
For the complete code, please refer to mail-example