PHPackages                             frankspress/sg-parser-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. frankspress/sg-parser-bundle

ActiveSymfony-bundle[Parsing &amp; Serialization](/categories/parsing)

frankspress/sg-parser-bundle
============================

Parses and validates SendGrid inbound email content sent to the WebHook - Symfony 5

1.0.0(6y ago)13MITPHPPHP ^7.1.3

Since Mar 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/frankspress/sg-parser-bundle)[ Packagist](https://packagist.org/packages/frankspress/sg-parser-bundle)[ RSS](/packages/frankspress-sg-parser-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

SgParserBundle
==============

[](#sgparserbundle)

Parses and validates SendGrid email/attachments sent to the WebHook ( Symfony 5 )

Requirements
------------

[](#requirements)

- PHP 7.1.3 or higher;
- Symfony 5.\*.

Installation
------------

[](#installation)

```
composer require frankspress/sg-parser-bundle
```

Usage
-----

[](#usage)

Create a new route and set the `prefix` to configure your new Webhook point.

```
# app/routes/sg_api_parser.yml

sg_api_parsers:
    resource: '@FrankspressSgParserBundle/Resources/config/routes.xml'
    prefix: '/api/sendgrid/inbound'
    trailing_slash_on_root: false
```

Create a new EventSubscriber. This will automatically be called when a new email is sent to your Api point.

```
namespace App\EventSubscriber;

use Frankspress\SgParserBundle\Attachment\NewAttachment;
use Frankspress\SgParserBundle\Event\ParserApiCompleteEvent;
use Frankspress\SgParserBundle\Event\SgParserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class SgParseEmail implements EventSubscriberInterface
{

    public static function getSubscribedEvents()
    {
        return [
                    SgParserEvents::PARSER_API => 'onParserApiComplete'
               ];
    }

    public function onParserApiComplete(ParserApiCompleteEvent $event )
    {
        $email = $event->getNewEmail();
        $attachments = $event->getNewAttachment();

        // SAVE YOUR EMAIL/ATTACHMENTS

    }
}
```

#### Default Config

[](#default-config)

To modify any of the default parameters create a config file and change any of the following. For instance, if you want the bundle to allow only specific mime types then you can list them in `mime_types`.

```
# app/config/sg_parser.yml

frankspress_sg_parser:

  email:

    max_body_length: 6000

    # Returns the email body or response body without the reply history and tags.
    raw_response: false

    # Returns the subject without RE:, FWD: etc
    raw_subject: false

  attachment:
    # Enables or disables attachment.
    handle_attachment: true

    # Searches for php injection in every attachment.
    php_injection: false

    file_upload_size: '6M'

    # Lists the mime types allowed. If empty or commented out "all" mime types will be allowed.
    # mime_types: [  'image/*',
    #                'application/pdf',
    #                'application/msword',
    #                'text/plain'
    # ]

```

Basic Example
-------------

[](#basic-example)

```
  // ...
  public function onParserApiComplete(ParserApiCompleteEvent $event )
  {
    $email = $event->getNewEmail();
    $attachments = $event->getNewAttachment();

   /*
    $email->getAttachment();
    $email->getSubject();
    $email->getSenderEmail();
    $email->getSenderName();
    $email->getBody();
    */
    if ( !empty($email->getAttachment() ) ) {

      foreach ($attachments as $attachment ) {
        /*
        $attachment->getFile();
        $attachment->getFileName();
        $attachment->getOriginalFileName();
        $attachment->error();
        $attachment->getFilePath();
        $attachment->getSize();
        $attachment->getType();
        */
      }
    }

  }
```

Methods are pretty much self explanatory. `$email->getAttachments()` returns an array with the attachment titles not the actual attachments.

`$attachments` comes as an array of attachments. From the example above you can see that for each attachment you can load its actual file with `$attachment->getFile()` or get it's filename with `$attachment->getFileName()`. One important note about `$attachment->error()`, if this is empty the file has passed validation, if it's not empty then only the first encountered error will be recorded.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2240d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb132b63bf9e92c491cf4d9969af0ac13ff87f6c5154642a990646f1cae29ed0?d=identicon)[frankspress](/maintainers/frankspress)

---

Top Contributors

[![frankspress](https://avatars.githubusercontent.com/u/58236464?v=4)](https://github.com/frankspress "frankspress (12 commits)")

---

Tags

email-validationinboundinbound-emailsendgridsendgrid-inbound-webhook-parsersymfonysymfony-bundlesymfony5

### Embed Badge

![Health badge](/badges/frankspress-sg-parser-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/frankspress-sg-parser-bundle/health.svg)](https://phpackages.com/packages/frankspress-sg-parser-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
