Last active
August 29, 2015 13:57
Revisions
-
AmyStephen revised this gist
Mar 8, 2014 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -86,19 +86,19 @@ class Swiftmailer extends AbstractHandler implements EmailInterface $class = 'Molajo\\Email\\Swiftmailer'; $handler = new $class($options); // 2. Instantiate the Email class, injecting it with the Handler. $class = 'Molajo\\Email'; $email = new $class($handler); // 3. Set email parameters $email->set('to', '[email protected],Fname Lname'); $email->set('from', '[email protected],Fname Lname'); $email->set('reply_to', '[email protected],FName LName'); $email->set('cc', '[email protected],FName LName'); $email->set('bcc', '[email protected],FName LName'); $email->set('subject', 'Welcome to our Site'); $email->set('body', 'Stuff goes here'); $email->set('mailer_html_or_text', 'text'); // 4. Send Email. $email->send(); -
AmyStephen revised this gist
Mar 8, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,9 +82,8 @@ class Swiftmailer extends AbstractHandler implements EmailInterface $options = array(); $options['mailer_transport'] = 'mail'; $options['site_name'] = 'Sitename'; $class = 'Molajo\\Email\\Swiftmailer'; $handler = new $class($options); // 2. Instantiate the Adapter, injecting it with the Handler. -
AmyStephen created this gist
Mar 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,105 @@ <?php class Email implements EmailInterface { /** * Email Handler * * @var object * @since 1.0 */ protected $handler; /** * Constructor * * @param EmailInterface $email * * @since 1.0 */ public function __construct(EmailInterface $email) { $this->handler = $email; } /** * Return parameter value or default * * @param string $key * @param string $default * * @return mixed * @since 1.0 */ public function get($key, $default = null) { return $this->handler->get($key, $default); } /** * Set parameter value * * @param string $key * @param mixed $value * * @return $this * @since 1.0 */ public function set($key, $value = null) { $this->handler->set($key, $value); return $this; } /** * Send Email * * @return mixed * @since 1.0 */ public function send() { $this->handler->send(); return $this; } } class PhpMailer extends AbstractHandler implements EmailInterface { // get, set, send methods that interact with phpMailer } class Swiftmailer extends AbstractHandler implements EmailInterface { // get, set, send methods that interact with Swiftmailer } // To use // 1. Instantiate an Email Handler. $options = array(); $options['mailer_transport'] = 'mail'; $options['site_name'] = 'Sitename'; $options['Fieldhandler'] = new Fieldhandler(); $class = 'Molajo\\Email\\Handler\\Swiftmailer'; $handler = new $class($options); // 2. Instantiate the Adapter, injecting it with the Handler. $class = 'Molajo\\Email'; $this->adapter = new $class($handler); // 3. Set email parameters $this->adapter->set('to', '[email protected],Fname Lname'); $this->adapter->set('from', '[email protected],Fname Lname'); $this->adapter->set('reply_to', '[email protected],FName LName'); $this->adapter->set('cc', '[email protected],FName LName'); $this->adapter->set('bcc', '[email protected],FName LName'); $this->adapter->set('subject', 'Welcome to our Site'); $this->adapter->set('body', 'Stuff goes here'); $this->adapter->set('mailer_html_or_text', 'text'); // 4. Send Email. $this->adapter->send();