pub struct EmailClient { /* private fields */ }Expand description
Email client for sending templated emails
Provides a high-level interface for sending emails using SMTP. Handles template rendering, connection pooling, and error handling.
§Example
ⓘ
use gatekpr_email::{EmailClient, EmailConfig};
let config = EmailConfig::from_env()?;
let client = EmailClient::new(config)?;
// Send a simple email
client.send_simple(
"user@example.com",
"Welcome!",
"<h1>Hello!</h1>",
"Hello!",
).await?;Implementations§
Source§impl EmailClient
impl EmailClient
Sourcepub fn new(config: EmailConfig) -> Result<Self>
pub fn new(config: EmailConfig) -> Result<Self>
Sourcepub async fn send<T: EmailTemplate>(&self, template: T) -> Result<()>
pub async fn send<T: EmailTemplate>(&self, template: T) -> Result<()>
Sourcepub async fn send_simple(
&self,
to: &str,
subject: &str,
html: &str,
text: &str,
) -> Result<()>
pub async fn send_simple( &self, to: &str, subject: &str, html: &str, text: &str, ) -> Result<()>
Send a simple email with HTML and text content
§Arguments
to- Recipient email addresssubject- Email subjecthtml- HTML contenttext- Plain text content
Sourcepub async fn test_connection(&self) -> Result<()>
pub async fn test_connection(&self) -> Result<()>
Sourcepub fn config(&self) -> &EmailConfig
pub fn config(&self) -> &EmailConfig
Get the underlying configuration
Sourcepub fn renderer(&self) -> &TemplateRenderer
pub fn renderer(&self) -> &TemplateRenderer
Get the template renderer
Auto Trait Implementations§
impl Freeze for EmailClient
impl !RefUnwindSafe for EmailClient
impl Send for EmailClient
impl Sync for EmailClient
impl Unpin for EmailClient
impl !UnwindSafe for EmailClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more