PHP code example of saloodo / mail-bundle

1. Go to this page and download the library: Download saloodo/mail-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/ */

    

saloodo / mail-bundle example snippets





//AppBundle/Mail/AccountApprovedEmail.php
namespace AppBundle\Mail;

use Saloodo\MailBundle\AbstractEmail;

class AccountApprovedEmail extends AbstractEmail
{
    const EXTERNAL_KEY = 11378;

    public function setConfimationLink($confirmationLink): void
    {
        $this->addToPayload("confirmation_link", $confirmationLink);
    }
}


//AppBundle/Controller/SomeController.php
namespace AppBundle\Controller;

use Saloodo\MailBundle\Sender;

class SomeController
{
    protected $sender;
    
    public function __construct(Sender $sender) 
    {
        $this->sender = $sender;   
    }
    
    protected function doAction(UserInterface $user)
    {
        $email = new AccountApprovedEmail();
        
        $email->setTo($user->getEmail(), $user->getName());
        $email->setConfimationLink("https://www.google.com");

        $emailSender->send($email);
    }
}