every one ,can anyone tell me please what are the difference between core/email_template_mailer
and core/email_template
…I want to know its each function in details.
Magento 1.7 Email – Difference Between core/email_template and core/email_template_mailer
emailemail-templatesmagento-1.7
Best Answer
One big difference is
setReplyTo()
(My Magento version is 1.7.0.1)
I added
setReplyTo()
functionality to theemail_template_mailer
via a customization of a core file:app/code/local/Mage/Core/Model/Email/Template/Mailer.php
Why? Because it was easier to add a couple lines of code than to rewrite the code utilizing
email_template_mailer
to send Admin copies of order emails. I wanted the emails to come showing the customers' name and having their email as Reply-To.Note that changing the From Email to their email gets you blacklisted, so I change the From Name and for the From Email use my own auto-confirm@ address.
While reviewing the two files:
app/code/core/Mage/Core/Model/Email/Template.php
and
app/code/core/Mage/Core/Model/Email/Template/Mailer.php
I concluded that
email_template_mailer
is a simplified wrapper foremail_template
, probably a result of how difficult it used to be to just send an email.The core file app/code/core/Mage/Core/Model/Email/Template/Mailer.php uses
email_template
:line 64:
$emailTemplate = Mage::getModel('core/email_template');
and then goes on to use
sendTransactional()
just like sending email had always been.app/code/core/Mage/Core/Model/Email/Template.php defines the method
sendTransactional()
as well as instantiates a private Zend_Mail member object:line 141:
$this->_mail = new Zend_Mail('utf-8');
sendTransactional()
is a wrapper for the public methodsend()
, which does the heavy lifting building the email forZend_Mail
. Thesend()
function populates out the various headers and prepares the body's plain text or HTML content with$this->getProcessedTemplate($variables, true);
. And then thissend()
callsZend_Mail
's ownsend()
.The big deal here is that Varien made the
email_template
to minimize the need for directly editing code by translating the templates and variables in the database into useful emails.