Source for file Email.php

Documentation is available at Email.php

  1. <?php
  2. /**
  3.  * This class wraps the Basic email sending functionality
  4.  * If SMTPPro is enabled it will send emails using the given
  5.  * configuration.
  6.  *
  7.  *
  8.  *
  9.  * @author Ashley Schroder (aschroder.com)
  10.  * @copyright  Copyright (c) 2010 Ashley Schroder
  11.  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  12.  */
  13.  
  14.  
  15.     public function send({
  16.          
  17.         // If it's not enabled, just return the parent result.
  18.         if (!Mage::helper('smtppro')->isEnabled()) {
  19.             return parent::send();
  20.         }
  21.  
  22.         Mage::log('SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email');
  23.          
  24.         // The remainder of this function closely mirrors the parent
  25.         // method except for providing the SMTP auth details from the
  26.         // configuration. This is not good OO, but the parent class
  27.         // leaves little room for useful subclassing.
  28.          
  29.         if (Mage::getStoreConfigFlag('system/smtp/disable')) {
  30.             return $this;
  31.         }
  32.  
  33.         $mail Mage::getModel('emailimages/mail');
  34.  
  35.         if (strtolower($this->getType()) == 'html'{
  36.             $mail->setBodyHtml($this->getBody());
  37.         }
  38.         else {
  39.             $mail->setBodyText($this->getBody());
  40.         }
  41.  
  42.         $transport Mage::helper('smtppro')->getTransport();
  43.         $dev Mage::helper('smtppro')->getDevelopmentMode();
  44.  
  45.         if ($dev == "contact"{
  46.              
  47.             $email Mage::getStoreConfig('contacts/email/recipient_email');
  48.             Mage::log("Development mode set to send all emails to contact form recipient: " $email);
  49.                 
  50.         elseif ($dev == "supress"{
  51.              
  52.             Mage::log("Development mode set to supress all emails.");
  53.             # we bail out, but report success
  54.             return $this;
  55.              
  56.         else {
  57.              
  58.             // We just set the outgoing email as normal
  59.             $email $this->getToEmail();
  60.              
  61.         }
  62.  
  63.         $mail->setFrom($this->getFromEmail()$this->getFromName())
  64.             ->addTo($email$this->getToName())
  65.             ->setSubject($this->getSubject());
  66.  
  67.         // If we are using store emails as reply-to's set the header
  68.         if (Mage::helper('smtppro')->isReplyToStoreEmail()) {
  69.             
  70.             // Later versions of Zend have a method for this, and disallow direct header setting...
  71.             if (method_exists($mail"setReplyTo")) {
  72.                 $mail->setReplyTo($this->getSenderEmail()$this->getSenderName());
  73.             else {
  74.                 $mail->addHeader('Reply-To'$this->getSenderEmail());
  75.             }
  76.             Mage::log('ReplyToStoreEmail is enabled, just set Reply-To header: ' $this->getSenderEmail());
  77.         }
  78.  
  79.         Mage::log('About to send email');
  80.         $mail->send($transport);
  81.         Mage::log('Finished sending email');
  82.         
  83.         $body $this->getBody();
  84.         Mage::dispatchEvent('smtppro_email_after_send'
  85.              array('to' => $this->getToName(),
  86.                  'subject' => $this->getSubject(),
  87.                      'template' => "n/a"//TODO: is that true?
  88.                      'html' => (strtolower($this->getType()) == 'html'),
  89.                      'email_body' => $body));
  90.                  
  91.  
  92.         return $this;
  93.     }
  94. }

Documentation generated on Fri, 09 Oct 2015 03:37:10 +0200 by phpDocumentor 1.4.4