Package for more comfortable works with Nette\Mail\Message
- PHP 5.4 or higher
- nette/di 2.2 or higher
- nette/mail 2.2 or higher
- nette/application 2.2 or higher
The best way to install Kappa\Mail is using Composer
$ composer require kappa/mail:@dev
Register extension:
extensions:
messages: Kappa\Mail\DI\MailExtension
In config file you can define messages
messages:
messageName:
option: value
options:
- value
Message options corresponds with API
Nette\Mail\Massage
class
Actual options:
from
- stringsubject
- stringreturnPath
- stringpriority
- integerreplyTo
- arrayto
- arraycc
arraybcc
- arrayembeddedFile
- arrayattachment
- array
In your code:
class Model
{
private $messageFactory;
public function __construct(\Kappa\Mail\MessageFactory $messageFactory)
{
$this->messageFactory = $messageFactory;
}
public function sendMail(array $data)
{
$message = $this->messageFactory->createMessage('messageName', 'email_template.latte', $data);
//...
}
}