Created
July 14, 2015 02:31
-
-
Save nietzscheson/df16dcc572f330ca0dbe to your computer and use it in GitHub Desktop.
MailerService
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 | |
namespace AppBundle\Utils; | |
class MailerService | |
{ | |
private $contentType; | |
private $subject; | |
private $from; | |
private $mailer; | |
private $to; | |
private $body; | |
public function __construct(\Swift_Mailer $mailer) | |
{ | |
$this->mailer = $mailer; | |
$this->contentType = 'text/html'; | |
$this->subject = 'Subject'; | |
$this->from = array("[email protected]" => "example.com"); | |
} | |
public function msn($mail, $body, $subject = false) | |
{ | |
$message = \Swift_Message::newInstance() | |
->setContentType($this->contentType) | |
->setSubject($this->subject = $subject) | |
->setFrom($this->from) | |
->setTo($mail) | |
->setBody($body); | |
return $this->mailer->send($message); | |
} | |
} | |
?> |
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: | |
app.mailer_service: | |
class: AppBundle\Utils\MailerService | |
arguments: [@mailer] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment