[−][src]Crate sendgrid_rs
This crate is a wrapper around SendGrid's v3 API using builder patterns to construct a payload to send. This crate does not have batteries included, does not perform any validations, and makes no assumptions other than what's specified in SendGrid's API documentation. To actually call the API, you must use some other mechnism for the HTTP connection (such as the reqwest crate).
Everything stems from Message which you can construct using a
MessageBuilder. When you're done with the
MessageBuilder
call build()
to get the underlying Message
and to_json()
to get the
entire Message
output as a JSON string.
Examples
let api_payload = MessageBuilder::new( ContactBuilder::new("from@example.com").name("from").build(), "Subject Line!", ) .template_id("SENDGRID-TEMPLATE-ID") // Don't Actually send email. If you want to really send the email, delete the line below .mail_settings(MailSettingsBuilder::default().sandbox_mode().build()) .personalization( PersonalizationBuilder::default() .to(ContactBuilder::new("to@example.com").name("to").build()) .build(), ) .build() .to_json();
Re-exports
pub use crate::attachment::AttachmentBuilder; |
pub use crate::mail_settings::MailSettingsBuilder; |
pub use crate::message::MessageBuilder; |
pub use crate::personalization::PersonalizationBuilder; |
pub use crate::tracking_settings::GaTrackingSettingBuilder; |
pub use crate::tracking_settings::TrackingSettingsBuilder; |
Modules
attachment | |
mail_settings | |
message | |
personalization | |
tracking_settings |
Structs
Asm | Type used for SendGrid's asm fields for managing subscriptions
Use |
AsmBuilder | A builder pattern for constructing |
Contact | Struct that holds the data needed for the 'contact' section in the SendGrid API.
Use a |
ContactBuilder | Builder pattern for |
Content |
|