|
|
We have implemented SwiftMailer for you in this codebase. To use it, you may refer to this example.
|
|
|
|
|
|
```` php
|
|
|
|
|
|
// As an example we can use the Mailer service in a Controller.
|
|
|
// We can inject the service from the class Constructor.
|
|
|
class HelloController
|
|
|
{
|
|
|
/**
|
|
|
* @var Swift_Mailer
|
|
|
*/
|
|
|
protected $mailer;
|
|
|
|
|
|
/**
|
|
|
* @param Swift_Mailer $mailer
|
|
|
*/
|
|
|
public function __construct(Swift_Mailer $mailer)
|
|
|
{
|
|
|
$this->mailer = $mailer;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Then we can just call the Mailer from any Controller method.
|
|
|
$message = (new Swift_Message('Hello from PHP Challenge'))
|
|
|
->setFrom(['phpchallenge@jobsity.io' => 'PHP Challenge'])
|
|
|
->setTo(['user@domain.org'])
|
|
|
->setBody('SwiftMailer is awesome!.');
|
|
|
|
|
|
// Later just do the actual email sending.
|
|
|
$this->mailer->send($message);
|
|
|
````
|
|
|
|
|
|
For more information about SwiftMailer, please visit:
|
|
|
|
|
|
https://swiftmailer.symfony.com/docs/introduction.html
|
|
|
|
|
|
For additional information about the Dependency Container,
|
|
|
please refer to:
|
|
|
|
|
|
https://www.slimframework.com/docs/v4/concepts/di.html |
|
|
\ No newline at end of file |