howdy/mail/sendgrid

Send mail with SendGrid’s v3 Mail Send API.

let assert Ok(config) = sendgrid.from_env()
let mailer = mail.mailer(sendgrid.adapter(config))

SendGrid needs at least one To recipient, and refuses an address that appears twice, so one already in To is dropped from Cc and Bcc. Tags become categories (SendGrid keeps the first ten), and the message’s id is sent as the custom argument howdy_id. For the EU region, set base_url to https://api.eu.sendgrid.com.

Types

pub opaque type Config

Values

pub fn adapter(config: Config) -> mail.Adapter
pub fn base_url(config: Config, url: String) -> Config

Where the API is, without a trailing slash. Default https://api.sendgrid.com.

pub fn from_env() -> Result(Config, Nil)

Read the API key from SENDGRID_API_KEY.

pub fn new(api_key: String) -> Config
pub fn receipt(
  outgoing: mail.Outgoing,
  response: response.Response(String),
) -> Result(mail.Receipt, mail.Error)

The receipt for SendGrid’s response to request: 202 Accepted, with its id in X-Message-Id.

pub fn request(
  config: Config,
  outgoing: mail.Outgoing,
) -> Result(request.Request(String), mail.Error)

The request adapter sends.

pub fn timeout(config: Config, milliseconds: Int) -> Config

How long to wait for SendGrid. Default 15 seconds.

✨ Search Document