pub struct SmtpReply { /* private fields */ }Expand description
SMTP reply line metadata.
Implementations§
Source§impl SmtpReply
impl SmtpReply
Sourcepub fn new(
code: SmtpReplyCode,
text: impl AsRef<str>,
) -> Result<SmtpReply, SmtpError>
pub fn new( code: SmtpReplyCode, text: impl AsRef<str>, ) -> Result<SmtpReply, SmtpError>
Creates a reply without enhanced status metadata.
Examples found in repository?
examples/email_facade_basic_usage.rs (line 14)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let mailbox = address::Mailbox::new(Some("Jane Doe"), "jane@example.com")?;
5 let message_id: id::MessageId = "welcome@example.com".parse()?;
6 let message = message::EmailMessage::plain_text("Welcome", "A short note.")
7 .with_header("From", mailbox.to_string())?;
8 let envelope = envelope::Envelope::new(envelope::EnvelopeSender::new("bounce@example.com")?)
9 .with_recipient(envelope::EnvelopeRecipient::new("jane@example.com")?);
10 let mailto_uri = mailto::MailtoBuilder::new()
11 .to("jane@example.com")?
12 .subject("Welcome")
13 .build();
14 let reply = smtp::SmtpReply::new(smtp::SmtpReplyCode::new(250)?, "OK")?;
15 let spf = auth::spf::SpfRecord::new().with_term(auth::spf::SpfTerm::new(
16 auth::spf::SpfQualifier::Fail,
17 auth::spf::SpfMechanism::All,
18 ));
19
20 assert_eq!(message.subject(), Some("Welcome"));
21 assert_eq!(message_id.to_string(), "<welcome@example.com>");
22 assert_eq!(envelope.recipients().len(), 1);
23 assert_eq!(
24 mailto_uri.to_string(),
25 "mailto:jane@example.com?subject=Welcome"
26 );
27 assert_eq!(reply.to_string(), "250 OK");
28 assert_eq!(spf.to_string(), "v=spf1 -all");
29
30 Ok(())
31}Sourcepub fn with_enhanced_status(
code: SmtpReplyCode,
enhanced_status: Option<SmtpEnhancedStatusCode>,
text: impl AsRef<str>,
) -> Result<SmtpReply, SmtpError>
pub fn with_enhanced_status( code: SmtpReplyCode, enhanced_status: Option<SmtpEnhancedStatusCode>, text: impl AsRef<str>, ) -> Result<SmtpReply, SmtpError>
Creates a reply with optional enhanced status metadata.
Sourcepub const fn code(&self) -> SmtpReplyCode
pub const fn code(&self) -> SmtpReplyCode
Returns the reply code.
Trait Implementations§
impl Eq for SmtpReply
impl StructuralPartialEq for SmtpReply
Auto Trait Implementations§
impl Freeze for SmtpReply
impl RefUnwindSafe for SmtpReply
impl Send for SmtpReply
impl Sync for SmtpReply
impl Unpin for SmtpReply
impl UnsafeUnpin for SmtpReply
impl UnwindSafe for SmtpReply
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