Source for file Template.php
Documentation is available at Template.php
* This class wraps the Newsletter email sending functionality
* If SMTPPro is enabled it will send emails using the given
* @author Ashley Schroder (aschroder.com)
* @copyright Copyright (c) 2010 Ashley Schroder
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Send mail to subscriber
* @param array $variables template variables
* @param string|null $name receiver name (if subscriber model not specified)
if(!$this->isValidForSend()) {
// If it's not enabled, just return the parent result.
if (!Mage::helper('smtppro')->isEnabled()) {
return parent::send($subscriber, $variables, $name, $queue);
Mage::log('SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Newsletter_Template');
$email =
$subscriber->getSubscriberEmail();
if (is_null($name) &&
($subscriber->hasCustomerFirstname() ||
$subscriber->hasCustomerLastname()) ) {
$name =
$subscriber->getCustomerFirstname() .
' ' .
$subscriber->getCustomerLastname();
$email = (string)
$subscriber;
// This is important for SPAM I think, what value should it be?
$mail->setReturnPath($this->getTemplateSenderEmail());
$transport =
Mage::helper('smtppro')->getTransport();
$dev =
Mage::helper('smtppro')->getDevelopmentMode();
$email =
Mage::getStoreConfig('contacts/email/recipient_email');
Mage::log("Development mode set to send all emails to contact form recipient: " .
$email);
} elseif ($dev ==
"supress") {
Mage::log("Development mode set to supress all emails.");
# we bail out, but report success
$mail->addTo($email, $name);
$text =
$this->getProcessedTemplate($variables, true);
$mail->setBodyText($text);
$mail->setBodyHTML($text);
$mail->setSubject($this->getProcessedTemplateSubject($variables));
$mail->setFrom($this->getTemplateSenderEmail(), $this->getTemplateSenderName());
// If we are using store emails as reply-to's set the header
if (Mage::helper('smtppro')->isReplyToStoreEmail()) {
// Later versions of Zend have a method for this, and disallow direct header setting...
$mail->setReplyTo($this->getTemplateSenderEmail(), $this->getTemplateSenderName());
$mail->addHeader('Reply-To', $this->getTemplateSenderEmail());
Mage::log('ReplyToStoreEmail is enabled, just set Reply-To header: ' .
$this->getTemplateSenderEmail());
Mage::log('About to send email');
Mage::log('Finished sending email');
Mage::dispatchEvent('smtppro_email_after_send',
'template' =>
$this->getTemplateId(),
'subject' =>
$mail->getSubject(),
'html' =>
!$this->isPlain(),
$subscriber->received($queue);
// If letter sent for subscriber, we create a problem report entry
$problem =
Mage::getModel('newsletter/problem');
$problem->addSubscriberData($subscriber);
$problem->addQueueData($queue);
$problem->addErrorData($e);
$subscriber->received($queue);
// Otherwise throw error to upper level
Documentation generated on Fri, 09 Oct 2015 03:37:11 +0200 by phpDocumentor 1.4.4