[−][src]Struct mailjet_rs::v3::Message
Mailjet's SendAPI V3 Message
Recipients listed in the Recipients
Vec
will
each receive a separate message without showing all other
recipients.
Example
use mailjet_rs::common::Recipient; use mailjet_rs::v3::Message; 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 recipients = vec![Recipient::new("receiver.email@mail.com")]; let message = Message::new( "your.mailjet.email@yourcompany.com", "Sender Name", Some(String::from("Testing Mailjet Rust with Send API v3 Message")), "This is a test on mailjet-rs with Send API v3 sending a basic email", Some(String::from("<h1>Some HTML to give it a try</h1>")), recipients, ); client.send(message).await; Ok(()) }
Send to multiple recipients
To send the same email to multiple contacts, add multiple Recipient
intances
to the recipients
field.
Each recipient will receive a dedicated message.
use mailjet_rs::common::Recipient; use mailjet_rs::v3::Message; 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 recipients = vec![ Recipient::new("receiver.email@mail.com"), Recipient::new("foo@bar.com"), Recipient::new("bar@baz.com")]; let message = Message::new( "your.mailjet.email@yourcompany.com", "Sender Name", Some(String::from("Testing Mailjet Rust with Send API v3 Message")), "This is a test on mailjet-rs with Send API v3 sending a basic email", Some(String::from("<h1>Some HTML to give it a try</h1>")), recipients, ); let response = client.send(message).await; println!("{:?}", response); 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
recipients: Vec<Recipient>
attachments: Option<Vec<Attachment>>
inline_attachments: Option<Vec<Attachment>>
Implementations
impl Message
[src]
pub fn new(
from_email: &str,
from_name: &str,
subject: Option<String>,
text_part: &str,
html_part: Option<String>,
recipients: Vec<Recipient>
) -> Self
[src]
from_email: &str,
from_name: &str,
subject: Option<String>,
text_part: &str,
html_part: Option<String>,
recipients: Vec<Recipient>
) -> Self
pub fn attach(&mut self, attachment: Attachment)
[src]
Attach an Attachment
to the Message
The recipient of a email with attachment will
have to click to see it. The inline attachment can be
visible directly in the body of the message depending
of the email client support.
The content will need to be Base64 encoded. You will need to specify the MIME type and a file name.
Remember to keep the size of your attachements low and not to exceed 15 MB.
pub fn attach_inline(&mut self, attachment: Attachment)
[src]
Attach an Attachment
to the Message
When using an inline Attachment, it's possible to insert
the file inside the HTML code of the email by using cid:FILENAME.EXT
where FILENAME.EXT is the Filename specified in the declaration of the Attachment.
The content will need to be Base64 encoded. You will need to specify the MIME type and a file name.
Remember to keep the size of your attachements low and not to exceed 15 MB.
Trait Implementations
impl Debug for Message
[src]
impl<'de> Deserialize<'de> for Message
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Payload for Message
[src]
impl Serialize for Message
[src]
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
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>,