gsquire / sendgrid-rs

Unofficial Rust library for the SendGrid API
https://crates.io/crates/sendgrid
MIT License
107 stars 50 forks source link

How to disable tracking? #108

Closed szabgab closed 9 months ago

szabgab commented 9 months ago

I am using the following code to send messages via sendgrid. I was trying to open and click tracking. I found TrackingSettings, but so far I have not understood how to use it. It would be nice if you could add an example doing so.

use sendgrid::SGClient;
use sendgrid::{Destination, Mail};

use crate::EmailAddress;

pub async fn sendgrid(
    api_key: &str,
    from: &EmailAddress,
    to: &EmailAddress,
    subject: &str,
    html: &str,
) {
    let sg = SGClient::new(api_key);

    let mail_info = Mail::new()
        .add_to(Destination {
            address: &to.email,
            name: &to.name,
        })
        .add_from(&from.email)
        .add_from_name(&from.name)
        .add_subject(subject)
        .add_html(html);

    sg.send(mail_info).await.ok();
}
szabgab commented 9 months ago

and I've managed to do it in #109

gsquire commented 9 months ago

I'm going to close this since it was handled in your PR. Feel free to open this again or create another issue if need be.