Closed
Description
Description
The current SendGrid Mailer Transport does not provide a mechanism to bypass suppressions. According to SendGrid documentation, there is a field called "mail_settings" where some options can be specified and there is no way to use it now.
Possible Implementation
Symfony\Component\Mime\Email
private $customFields = [];
public function setCustomField(string $field, $value)
{
$this->customFields[$field] = $value;
return $this;
}
public function getCustomField(string $field)
{
if (key_exists($this->customFields, $field)) {
return $this->customFields[$field];
}
return null;
}
Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridApiTransport
private function getPayload(Email $email, Envelope $envelope): array
{
// ...
if ($bypassSuppression = $email->getCustomField('bypass_suppression')) {
$payload['mail_settings']['bypass_unsubscribe_management'] = $bypassSuppression;
}
// ...
}
This is an important option for transactional emails in SendGrid. If changing Email
class is not an option, what's an alternative solution to this?