Skip to content

Instantly share code, notes, and snippets.

@nietzscheson
Created July 14, 2015 02:31
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 nietzscheson/df16dcc572f330ca0dbe to your computer and use it in GitHub Desktop.
Save nietzscheson/df16dcc572f330ca0dbe to your computer and use it in GitHub Desktop.
MailerService
<?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("no-reply@example.com" => "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);
}
}
?>
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