Skip to content

Symfony bundle for SendGrid. Utilizes the SendGrid PHP Library https://github.com/sendgrid/sendgrid-php to make it compatible with SwiftMailer

License

Notifications You must be signed in to change notification settings

expertcoder/SwiftmailerSendGridBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Freelance Banner

SwiftmailerSendGridBundle

Latest Version Software License Build Status

Symfony bundle for SendGrid. Utilizes the SendGrid PHP Library https://github.com/sendgrid/sendgrid-php to make it compatiable with SwiftMailer.

Older version (1.x) can be found here: https://github.com/expertcoder/SwiftmailerSendGridBundle/tree/1.x

Installation

composer require expertcoder/swiftmailer-send-grid-bundle

or manually

composer.json

"require": {
    ...
    "expertcoder/swiftmailer-send-grid-bundle": "~2.0"
}

config/packages/swiftmailer.yaml

swiftmailer:
    transport: expertcoder_swift_mailer.send_grid

Don't forget to set your Sendgrid API Key in your .env file, and that you can set your mail's categories from config/packages/expert_coder_swiftmailer_send_grid.yaml

Applications that don't use Symfony Flex

AppKernel.php

$bundles = [
    // ...
    new ExpertCoder\Swiftmailer\SendGridBundle\ExpertCoderSwiftmailerSendGridBundle(),
];

parameters.yml.dist

parameters:
    sendgrid_api_key: PleaseEnterSendGridApiKey

config.yml

swiftmailer:
    transport: expertcoder_swift_mailer.send_grid
    
expert_coder_swiftmailer_send_grid:
    api_key: %sendgrid_api_key%
    categories: [my_category] # optional, will be added to all mails sent (can be seen on sendgrid dashboard)

Important !

Following RFC 1341, section 7.2, if either text/html or text/plain are to be sent in your email: text/plain needs to be first, followed by text/html, followed by any other content.

For more informations, please see SwiftMailer and RFC 1341