Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mailer] SendGrid bypass suppressions #42854

Closed
@george-jipa-goodlord

Description

@george-jipa-goodlord

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions