pub struct MailMessage {
pub from: Option<MailAddress>,
pub reply_to: Option<MailAddress>,
pub to: Vec<MailAddress>,
pub cc: Vec<MailAddress>,
pub bcc: Vec<MailAddress>,
pub subject: String,
pub html_body: Option<String>,
pub text_body: Option<String>,
pub attachments: Vec<MailAttachment>,
}Expand description
邮件消息 — 对齐 PHP think\mail\Message
使用 Builder 模式构建邮件内容,通过 Mailer::send 发送。
§PHP 对齐
// PHP think\facade\Mail
Mail::to('user@example.com')
->subject('Hello')
->html('<h1>Welcome</h1>')
->send();§Rust 用法
ⓘ
use sz_rust_core::mail::{MailMessage, MemoryMailer};
let msg = MailMessage::new()
.to("user@example.com")
.subject("Hello")
.html("<h1>Welcome</h1>");
let mailer = MemoryMailer::new();
mailer.send(msg).unwrap();Fields§
§from: Option<MailAddress>发件人
reply_to: Option<MailAddress>回复地址
to: Vec<MailAddress>收件人列表
cc: Vec<MailAddress>抄送人列表
bcc: Vec<MailAddress>密送人列表
subject: String邮件主题
html_body: Option<String>HTML 内容
text_body: Option<String>纯文本内容
attachments: Vec<MailAttachment>附件列表
Implementations§
Source§impl MailMessage
impl MailMessage
Sourcepub fn from(self, address: impl Into<MailAddress>) -> Self
pub fn from(self, address: impl Into<MailAddress>) -> Self
Sourcepub fn reply_to(self, address: impl Into<MailAddress>) -> Self
pub fn reply_to(self, address: impl Into<MailAddress>) -> Self
设置回复地址
Sourcepub fn to(self, address: impl Into<MailAddress>) -> Self
pub fn to(self, address: impl Into<MailAddress>) -> Self
添加收件人(可多次调用累加)
Sourcepub fn cc(self, address: impl Into<MailAddress>) -> Self
pub fn cc(self, address: impl Into<MailAddress>) -> Self
添加抄送人(可多次调用累加)
Sourcepub fn bcc(self, address: impl Into<MailAddress>) -> Self
pub fn bcc(self, address: impl Into<MailAddress>) -> Self
添加密送人(可多次调用累加)
Sourcepub fn attach(self, attachment: MailAttachment) -> Self
pub fn attach(self, attachment: MailAttachment) -> Self
添加附件
Trait Implementations§
Source§impl Clone for MailMessage
impl Clone for MailMessage
Source§fn clone(&self) -> MailMessage
fn clone(&self) -> MailMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MailMessage
impl Debug for MailMessage
Source§impl Default for MailMessage
impl Default for MailMessage
Source§fn default() -> MailMessage
fn default() -> MailMessage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MailMessage
impl RefUnwindSafe for MailMessage
impl Send for MailMessage
impl Sync for MailMessage
impl Unpin for MailMessage
impl UnsafeUnpin for MailMessage
impl UnwindSafe for MailMessage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.