Source for file Email.php
Documentation is available at Email.php
* DotBoost Technologies Inc.
* DotKernel Application Framework
* @copyright Copyright (c) 2009 DotBoost Technologies (http://www.dotboost.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @version $Id: Email.php 152 2010-06-18 07:39:40Z teo $
* Alternate SMTP and default server mail() class
* @author DotKernel Team <team@dotkernel.com>
$this->settings = Zend_Registry::get('settings');
$this->db = Zend_Registry::get('database');
$this->addHeader('X-Mailer', $this->xmailer);
$this->seoOption = $seo->getOption();
* @param string $format [optional]
public function setContent ($content, $format = 'text/plain')
if ($format == 'text/html' )
parent::setBodyHtml($content);
parent::setBodyText($content);
* Send email. Parameter is included only to be compatible with Zend_Mail
* @param Zend_Mail_Transport_Abstract $transport [optional]
public function send($transport = null)
// set From and ReplyTo, in case we forgot it in code
parent::setDefaultFrom($this->settings->siteEmail, $this->seoOption->siteName);
parent::setDefaultReplyTo($this->settings->siteEmail, $this->seoOption->siteName);
// set the sendmail transporter as default
// check if we need to use an external SMTP
if('1' == $this->settings->smtpActive)
$partial = @explode('@', $this->_to[0]);
if(stristr($this->settings->smtpAddresses, $partial['1']) !== FALSE)
// we can't use SMTP in this case
$this->setDefaultTransport($tr->getTransport());
catch (Zend_Exception $e)
* @todo definitely we want to create an exception class, Other code to recover from the error
$devEmails = @explode(',', $this->settings->devEmails);
$dateNow = date('F dS, Y h:i:s A');
$mailSubject = "SMTP Error on ". $this->seoOption->siteName;
$mailContent = "We were unable to send SMTP email.". "\n";
$mailContent .= "---------------------------------". "\n";
$mailContent .= "Caught exception: ". get_class($e). "\n";
$mailContent .= "Message: ". $e->getMessage(). "\n";
$mailContent .= "---------------------------------". "\n\n";
$to = $this->getRecipients();
$mailContent .= "To Email: ". $to[0]. "\n";
$mailContent .= "From Email: ". $this->getFrom(). "\n";
$mailContent .= "Date: ". $dateNow . "\n";
$mailHeader = "From: ". $this->settings->siteEmail. "\r\n";
$mailHeader .= "Reply-To:". $this->settings->siteEmail. "\r\n". "X-Mailer: PHP/". phpversion();
foreach($devEmails as $ky => $mailTo)
mail($mailTo, $mailSubject, $mailContent, $mailHeader);
|