2017 © Pedro Peláez
 

library email-package

Basic classes for working with Emails on Nette

image

flame/email-package

Basic classes for working with Emails on Nette

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Email Package

Advanced emails with custom templates on Nette, (*1)

Instalation

Install the package via composer. Add into your dependencies: "flame/email-package": ">=2.0.0", (*2)

Register emails extension, (*3)

    \Flame\Email\DI\EmailsExtension::register($configurator);

Configure emails via config, (*4)

    emails:
        support: [sifalda.jiri@gmail.com, Support]

From this configuration will be created object of Flame\Email\EmailAddress which will be added into Flame\Email\EmailAddressContainer., (*5)

Example of usage

Create custom email, (*6)

use Enlan\UserModule\Entity\User;
use Flame\Email\EmailAddress;
use Flame\Email\IEmailFactory;
use Flame\Email\IFullMessageFactory;
use Nette\Object;

class Mailer extends Object
{

    /** @var  IEmailFactory */
    private $emailFactory;

    /** @var  IFullMessageFactory */
    private $messageFactory;

    /**
     * @param IEmailFactory $emailFactory
     * @param IFullMessageFactory $messageFactory
     */
    function __construct(IEmailFactory $emailFactory, IFullMessageFactory $messageFactory)
    {
        $this->emailFactory = $emailFactory;
        $this->messageFactory = $messageFactory;
    }

    /**
     * @param User $user
     */
    public function sendEmailsOnCreate(User $user)
    {
        $message = $this->messageFactory
            ->addTo(new EmailAddress($user->getEmail(), $user->getIdentifier()))
            ->setFrom('support')
            ->createMessage()
            ->setSubject('Hello');

        $email = $this->emailFactory
            ->createEmail()
            ->setMessage($message)
            ->setTemplateFile(__DIR__ . '/../templates/NewUserEmail.latte');

        $email->template->greeting = 'Hi, all!';
        $email->send();
    }
}

Template file, (*7)



Greeting

<p>{$greeting}</p> <a href="{plink //Homepage: }" target="_blank">Visit homepage</a>

Now, you can use Mailer for sending your advanced Nette emails :-), (*8)

The Versions

05/07 2014

dev-master

9999999-dev https://github.com/flame-org/Email-Package

Basic classes for working with Emails on Nette

  Sources   Download

BSD-2-Clause-FreeBSD

The Requires

 

email types nette flame

05/07 2014

v2.1.0

2.1.0.0 https://github.com/flame-org/Email-Package

Basic classes for working with Emails on Nette

  Sources   Download

BSD-2-Clause-FreeBSD

The Requires

 

email types nette flame

06/09 2013

v2.0.0

2.0.0.0 https://github.com/flame-org/Email-Package

Basic classes for working with Emails on Nette

  Sources   Download

BSD-2-Clause-FreeBSD

The Requires

 

email types nette flame

25/06 2013

v1.0.0

1.0.0.0 https://github.com/flame-org/Email-Package

Basic classes for working with Emails on Nette

  Sources   Download

BSD-2-Clause-FreeBSD

The Requires

 

email types nette flame