[−][src]Struct mda::Email
A representation of an email.
Methods
impl Email
[src]
pub fn filter(&self, cmd: &[&str]) -> Result<Email>
[src]
Filters the contents of the email using an external command, returning a new email with the filtered contents.
The command is expected to be provided as a &str
array, with the
first element being the command name and the remaining elements the
command arguments.
Example
use mda::Email; let email = Email::from_stdin()?; let email = email.filter(&["bogofilter", "-ep"])?;
pub fn process(&self, cmd: &[&str]) -> Result<Output>
[src]
Process the contents of the email using an external command,
returning a std::process::Output
for the executed command.
The command is expected to be provided as a &str
array, with the
first element being the command name and the remaining elements the
command arguments.
Example
use mda::Email; let email = Email::from_stdin()?; let output = email.process(&["bogofilter"])?; if let Some(0) = output.status.code() { email.deliver_to_maildir("/my/spam/path")?; }
pub fn from_stdin_filtered(cmd: &[&str]) -> Result<Self>
[src]
Creates an Email
by filtering the contents from stdin.
This can be more efficient than creating an Email
from stdin and
filtering separately, since it can avoid an extra data copy.
The command is expected to be provided as a &str
array, with the
first element being the command name and the remaining elements the
command arguments.
Example
use mda::Email; let email = Email::from_stdin_filtered(&["bogofilter", "-ep"])?;
impl Email
[src]
pub fn from_stdin() -> Result<Self>
[src]
pub fn from_vec(data: Vec<u8>) -> Result<Self>
[src]
Creates an Email
by using data passed in a Vec<u8>
.
Example
let email = Email::from_vec(vec![1, 2, 3])?;
pub fn set_delivery_durability(
&mut self,
delivery_durability: DeliveryDurability
)
[src]
&mut self,
delivery_durability: DeliveryDurability
)
Sets the durability method for delivery of this email.
Example
let mut email = Email::from_stdin()?; email.set_delivery_durability(DeliveryDurability::FileSyncOnly);
pub fn header_field(&self, name: &str) -> Option<&str>
[src]
Returns the value of a header field, if present. If a field occurs multiple times, the value of the first occurrence is returned.
Example
let email = Email::from_stdin()?; let to = email.header_field("To").unwrap_or("");
pub fn header_field_all_occurrences(&self, name: &str) -> Option<&Vec<String>>
[src]
Returns the values from all occurrences of a header field, if present.
Example
let email = Email::from_stdin()?; if let Some(all_received) = email.header_field_all_occurrences("Received") { // process all_received }
pub fn deliver_to_maildir(&self, path: impl AsRef<Path>) -> Result<PathBuf>
[src]
Delivers the email to the specified maildir. If the maildir isn't present it is created.
The first delivery of an email involves writing the email data to the target file, whereas subsequent deliveries try to use a hard link to the first delivery, falling back to a normal write if needed.
The email is delivered durably by syncing both the file and the
associated directories (DeliveryDurability::FileAndDirSync
),
unless a different durability method is specified with
set_delivery_durability
.
Example
let email = Email::from_stdin()?; email.deliver_to_maildir("/path/to/maildir/")?;
pub fn has_been_delivered(&self) -> bool
[src]
Returns whether the email has been delivered to at least one maildir.
Example
let email = Email::from_stdin()?; if !email.has_been_delivered() { email.deliver_to_maildir("/fallback/maildir/")?; }
pub fn data(&self) -> &[u8]
[src]
Provides access to the normalized email byte data.
pub fn header(&self) -> &[u8]
[src]
Provides access to the normalized email header byte data.
pub fn body(&self) -> &[u8]
[src]
Provides access to the normalized email body byte data.
pub fn raw_data(&self) -> &[u8]
[src]
Provides access to the raw (non-normalized) email byte data.
Auto Trait Implementations
impl Send for Email
impl Sync for Email
impl Unpin for Email
impl RefUnwindSafe for Email
impl UnwindSafe for Email
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,