PHP code example of neyric / inbound-email-bundle

1. Go to this page and download the library: Download neyric/inbound-email-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

neyric / inbound-email-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new \neyric\InboundEmailBundle\NeyricInboundEmailBundle(),
        ];

        // ...
    }

    // ...
}


use neyric\InboundEmailBundle\Event\InboundEmailEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class MyInboundEmailSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            InboundEmailEvent::class => ['onInboundEmail', 10], // 10 = priority
        ];
    }

    public function onInboundEmail(InboundEmailEvent $event)
    {
        // ... do something with $event
        // Check https://github.com/neyric/inbound-email-bundle/blob/master/Event/InboundEmailEvent.php for reference

        // If this subscriber can handle this event, it is recommended to stop the propagation
        // This will prevent other subscribers with lower priorities to be executed,
        // allowing event-based routing of your incoming emails.
        $event->stopPropagation();
    }
}