Skip to content

Commit

Permalink
minor #4808 Email message instantiation changed to a more 'symfonysh'…
Browse files Browse the repository at this point in the history
… way. (alebo)

This PR was merged into the 2.3 branch.

Discussion
----------

Email message instantiation changed to a more 'symfonysh' way.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |

I believe that using a static factory method for instantiation isn't the best way to do it in Symfony. So I suggest updating the Sending Emails example.

Commits
-------

7f8b051 Changed email message instantiation to a more 'symfonysh' way.
  • Loading branch information
wouterj committed Jan 16, 2015
2 parents e913808 + 7f8b051 commit 892586b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cookbook/email/email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ an email is pretty straightforward::

public function indexAction($name)
{
$message = \Swift_Message::newInstance()
$mailer = $this->get('mailer');
$message = $mailer->createMessage()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
Expand All @@ -114,7 +115,7 @@ an email is pretty straightforward::
)
)
;
$this->get('mailer')->send($message);
$mailer->send($message);

return $this->render(...);
}
Expand Down

0 comments on commit 892586b

Please sign in to comment.