pub struct NotificationPlugin { /* private fields */ }Expand description
通知插件:SMTP 邮件发送(基于 lettre)
从 NotificationConfig 读取 SMTP 连接信息,启动时建立连接。
根据发件人邮箱域名自动选择 STARTTLS 或默认 RELAY 传输方式。
若未启用或不可达,send_text() / send_html() 降级为跳过(不报错)。
Implementations§
Source§impl NotificationPlugin
impl NotificationPlugin
Sourcepub fn from_config(config: &NotificationConfig) -> Self
pub fn from_config(config: &NotificationConfig) -> Self
从配置创建通知插件
若 smtp_host 为空或 enabled = false,则邮件功能降级为跳过模式。
iCloud / Swisscows 等邮箱使用 STARTTLS 加密传输,其他使用默认 RELAY。
Sourcepub fn send_html(&self, to: &str, subject: &str, html_body: &str) -> Result<()>
pub fn send_html(&self, to: &str, subject: &str, html_body: &str) -> Result<()>
发送 HTML 邮件(同时附带纯文本版本,适配不同邮件客户端)
html_body 为 HTML 格式的邮件正文,内部自动生成纯文本备用版本。
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
邮件功能是否已配置
Trait Implementations§
Source§impl Plugin for NotificationPlugin
impl Plugin for NotificationPlugin
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
启动插件:验证连接、初始化资源 Read more
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
关闭插件:释放资源 Read more
Source§fn depends_on(&self) -> &[&str]
fn depends_on(&self) -> &[&str]
依赖的其他插件名称(用于拓扑排序,保证启动顺序) Read more
Auto Trait Implementations§
impl Freeze for NotificationPlugin
impl !RefUnwindSafe for NotificationPlugin
impl Send for NotificationPlugin
impl Sync for NotificationPlugin
impl Unpin for NotificationPlugin
impl UnsafeUnpin for NotificationPlugin
impl !UnwindSafe for NotificationPlugin
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