Skip to content

Instantly share code, notes, and snippets.

@Kcko
Forked from matej21/MessageFactory.php
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kcko/890ccd5c9f2315e622e8 to your computer and use it in GitHub Desktop.
Save Kcko/890ccd5c9f2315e622e8 to your computer and use it in GitHub Desktop.
Nette - správné použití odeslání emailu
services:
-
implement: MessageFactory
setup:
- setFrom("foo@bar.com")
<?php
interface MessageFactory
{
/**
* @return \Nette\Mail\Message
*/
public function create();
}
<?php
class FooService extends Nette\Object
{
protected $messageFactory;
protected $mailer;
public function __construct(Nette\Mail\IMailer $mailer, MessageFactory $messageFactory)
{
$this->messageFactory = $messageFactory;
$this->mailer = $mailer;
}
public function doSth()
{
$message = $this->messageFactory->create();
$message->setSubject(....);
$this->mailer->send($message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment