Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • PHP Challenge PHP Challenge
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Jobsity
  • PHP ChallengePHP Challenge
  • Wiki
  • Usage of the Mailer service (SwiftMailer)

Usage of the Mailer service (SwiftMailer) · Changes

Page history
Create Usage of the Mailer service (SwiftMailer) authored Jun 01, 2021 by Jobsity Admin's avatar Jobsity Admin
Hide whitespace changes
Inline Side-by-side
Showing with 40 additions and 0 deletions
+40 -0
  • Usage-of-the-Mailer-service-(SwiftMailer).md Usage-of-the-Mailer-service-(SwiftMailer).md +40 -0
  • No files found.
Usage-of-the-Mailer-service-(SwiftMailer).md 0 → 100644
View page @ 01a60f70
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
Clone repository
  • PHP Challenge Instructions
  • Usage of the Mailer service (SwiftMailer)
  • Using RabbitMQ with Slim Framework
  • Home