MessagingEmailProviderSendgrid
Send email through SendGrid: one class of static functions that deliver either a plain text message with an optional HTML body and attachments, or a SendGrid dynamic template filled with your own data.
This page is a pure reference. For how the framework fits together, see the Guide.
MessagingEmailProviderSendGrid- send email through SendGrid.
MessagingEmailProviderSendGrid
The SendGrid email provider: static functions that send an email through the SendGrid API using the configured API key. Each function validates its arguments, sends the message, and throws when SendGrid does not accept it.
Send
MessagingEmailProviderSendGrid::Send(string $fromEmail, string $fromName, string $toEmail, string $toName, string $subject, string $bodyText, string|null $optionalBodyHtml = null, array $attachments = []): void
Send an email through SendGrid with a plain text body, an optional HTML body, and optional attachments. Throws when SendGrid does not return a 202 accepted response.
| Name | Type | Description |
|---|---|---|
$fromEmail | string | The sender email address. |
$fromName | string | The sender display name. |
$toEmail | string | The recipient email address. |
$toName | string | The recipient display name. |
$subject | string | The email subject line. |
$bodyText | string | The plain text body of the email. |
$optionalBodyHtml | string|null | An HTML body to add, or null for none. |
$attachments | array | A map of attachment name to raw content; each is base64 encoded and attached. |
Returns void
SendGridTemplate
MessagingEmailProviderSendGrid::SendGridTemplate(string $fromEmail, string $fromName, string $toEmail, string $toName, string $templateId, array $dynamicData): void
Send an email through SendGrid using a dynamic template, supplying the values that fill it. Throws when SendGrid does not return a 202 accepted response.
| Name | Type | Description |
|---|---|---|
$fromEmail | string | The sender email address. |
$fromName | string | The sender display name. |
$toEmail | string | The recipient email address. |
$toName | string | The recipient display name. |
$templateId | string | The SendGrid dynamic template id to use. |
$dynamicData | array | A map of template variable name to value, added as dynamic template data. |
Returns void