Mage_Core_Model_Email Class Reference

Inheritance diagram for Mage_Core_Model_Email:

Varien_Object

List of all members.

Public Member Functions

 __construct ()
 setTemplateVar ($var, $value=null)
 getTemplateVars ()
 getBody ()
 getSubject ()
 send ()

Protected Attributes

 $_tplVars = array()
 $_block


Detailed Description

Possible data fields:

Definition at line 39 of file Email.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 44 of file Email.php.

00045     {
00046         // TODO: move to config
00047         $this->setFromName('Magento');
00048         $this->setFromEmail('magento@varien.com');
00049         $this->setType('text');
00050     }


Member Function Documentation

getBody (  ) 

Definition at line 70 of file Email.php.

00071     {
00072         $body = $this->getData('body');
00073         if (empty($body) && $this->getTemplate()) {
00074             $this->_block = Mage::getModel('core/layout')->createBlock('core/template', 'email')
00075                 ->setArea('frontend')
00076                 ->setTemplate($this->getTemplate());
00077             foreach ($this->getTemplateVars() as $var=>$value) {
00078                 $this->_block->assign($var, $value);
00079             }
00080             $this->_block->assign('_type', strtolower($this->getType()))
00081                 ->assign('_section', 'body');
00082             $body = $this->_block->toHtml();
00083         }
00084         return $body;
00085     }

getSubject (  ) 

Definition at line 87 of file Email.php.

00088     {
00089         $subject = $this->getData('subject');
00090         if (empty($subject) && $this->_block) {
00091             $this->_block->assign('_section', 'subject');
00092             $subject = $this->_block->toHtml();
00093         }
00094         return $subject;
00095     }

getTemplateVars (  ) 

Definition at line 65 of file Email.php.

00066     {
00067         return $this->_tplVars;
00068     }

send (  ) 

Definition at line 97 of file Email.php.

00098     {
00099         if (Mage::getStoreConfigFlag('system/smtp/disable')) {
00100             return $this;
00101         }
00102 
00103         $mail = new Zend_Mail();
00104 
00105         if (strtolower($this->getType()) == 'html') {
00106             $mail->setBodyHtml($this->getBody());
00107         }
00108         else {
00109             $mail->setBodyText($this->getBody());
00110         }
00111 
00112         $mail->setFrom($this->getFromEmail(), $this->getFromName())
00113             ->addTo($this->getToEmail(), $this->getToName())
00114             ->setSubject($this->getSubject());
00115         $mail->send();
00116 
00117         return $this;
00118     }

setTemplateVar ( var,
value = null 
)

Definition at line 52 of file Email.php.

00053     {
00054         if (is_array($var)) {
00055             foreach ($var as $index=>$value) {
00056                 $this->_tplVars[$index] = $value;
00057             }
00058         }
00059         else {
00060             $this->_tplVars[$var] = $value;
00061         }
00062         return $this;
00063     }


Member Data Documentation

$_block [protected]

Definition at line 42 of file Email.php.

$_tplVars = array() [protected]

Definition at line 41 of file Email.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:57 2009 for Magento by  doxygen 1.5.8