Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MailerAdapter
- {
- private $transport;
- public function __construct($name = 'Mailgun')
- {
- $this->setTransport($name);
- }
- public function setTransport($name)
- {
- $this->transport = new ($name . 'Transport');
- }
- public function send($email)
- {
- $this->transport->send($email);
- }
- }
- class MailgunTransport extends MailerAdapter
- {
- private $mailgun_api;
- public function __construct()
- {
- $this->mailgun_api = Mailgun::create($_ENV['MAILGUN_KEY']);
- }
- public function send($email)
- {
- $this->mailgun_api->send($email);
- }
- }
- class MailjetTransport extends MailerAdapter
- {
- private $mailjet_api;
- public function __construct()
- {
- $this->mailjet_api = new mailjet();
- }
- public function send($email)
- {
- $this->mailjet_api->send($email);
- }
- }
- $mailer = new MailerAdapter();
- $mailer->setTransport('Mailgun');
- $mailer->send('mon email');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement