-
-
Save Kcko/890ccd5c9f2315e622e8 to your computer and use it in GitHub Desktop.
Nette - správné použití odeslání emailu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
- | |
implement: MessageFactory | |
setup: | |
- setFrom("[email protected]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface MessageFactory | |
{ | |
/** | |
* @return \Nette\Mail\Message | |
*/ | |
public function create(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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