brevo-mail 0.2.0

Utility Crate to send transactional E-Mails via Brevo.
Documentation

Brevo Mail

Utility Crate to send transactional E-Mails via Brevo.

Code

Take a closer look at the examples folder.

...

#[derive(Parser, Debug)]
struct Cli {
    key: String,
    sender: String,
    to: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let cli = Cli::parse();

    let brevo_api_key = BrevoApiKey::from_str(&cli.key)?;

    let brevo_options = BrevoOptions::new(brevo_api_key, BrevoEndpoint::default());
    let brevo_client = BrevoClient::from_options(brevo_options)?;

    let sender = MailAddress::builder().mail(cli.sender).build()?;
    let to = MailAddress::builder().mail(cli.to).build()?;

    let mail = Mail::builder()
        .subject("Test Brevo Lib")
        .content(MailContent::text("Test Brevo Lib Content"))
        .sender(sender)
        .to(vec![to])
        .build()?;

    brevo_client.send(&mail).await?;

    Ok(())
}```

## Brevo Docs

https://developers.brevo.com/docs/send-a-transactional-email

## Brevo API Keys

https://app.brevo.com/settings/keys/api

## Brevo API Reference

https://developers.brevo.com/reference/sendtransacemail

## Example

The example in the `examples` folder shows you how to use the library. You can call the example with:

```bash
cargo run --example send_mail xkeysib-brevo-key <sender-mail> <receiver-mail>