[][src]Struct mailjet_rs::v3::Email

pub struct Email {
    pub from_email: String,
    pub from_name: String,
    pub subject: Option<String>,
    pub text_part: String,
    pub html_part: Option<String>,
    pub to: Vec<Recipient>,
    pub cc: Option<Vec<Recipient>>,
    pub bcc: Option<Vec<Recipient>>,
}

Mailjet's SendAPI V3 Email

Recipients listed in To will receive a common message showing every other recipients and carbon copies recipients.

When using To, Cc and Bcc instead of Recipients, the email addresses need to be presented as SMTP headers in a string and not as an array.

Note: If a recipient does not exist in any of your contact list it will be created from scratch, keep that in mind if you are planning on sending a welcome email and then you're trying to add the email to a list as the contact effectively exists already.

Example

This example is not tested
use mailjet_rs::common::Recipient;
use mailjet_rs::v3::Email;
use mailjet_rs::{Client, SendAPIVersion};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let client = Client::new(
        SendAPIVersion::V3,
        "public_key",
        "private_key",
    );

    let to = vec![Recipient::new("foo@bar.com")];
    let cc = vec![Recipient::new("bar@baz.com"), Recipient::new("boo@baz.com")];
    let bcc = vec![Recipient::new("bar_baz_box@mail.com")];

    let message = Email::new(
        "your.mailjet.email@yourcompany.com",
        "Sender Name",
        "Subject",
        "Email Content",
        Some(String::from("<h1>HTML Content for Email</h1>")),
        to,
        Some(cc),
        Some(bcc)
    );

    client.send(message).await;

    Ok(())
}

Fields

from_email: String

The verified sender email address

from_name: String

The name of the sender

subject: Option<String>

The subject of the email

text_part: String

The raw text content of the email

html_part: Option<String>

The HTML content of the email

to: Vec<Recipient>cc: Option<Vec<Recipient>>bcc: Option<Vec<Recipient>>

Implementations

impl Email[src]

pub fn new(
    from_email: &str,
    from_name: &str,
    subject: Option<String>,
    text_part: &str,
    html_part: Option<String>,
    to: Vec<Recipient>,
    cc: Option<Vec<Recipient>>,
    bcc: Option<Vec<Recipient>>
) -> Self
[src]

Trait Implementations

impl Debug for Email[src]

impl<'de> Deserialize<'de> for Email[src]

impl Payload for Email[src]

impl Serialize for Email[src]

Auto Trait Implementations

impl RefUnwindSafe for Email

impl Send for Email

impl Sync for Email

impl Unpin for Email

impl UnwindSafe for Email

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.