Add replyTo in Magento Transactional Email

3.6k Views Asked by At

What I'm trying to do is to add a replyto field to the core transactional emails of magento. Something like what was archieved in this post with bcc, but for replyTo. Any ideia?

Update: Just to clarify this a little. In the magento TEMPLATE class it is possible to add the replyTo header (core function), but in the MAILER class it is not possible to do that. And that is what I need.

3

There are 3 best solutions below

0
On BEST ANSWER

There’s no need to extend any class.

Just use:

$mailTemplate = Mage::getModel('core/email_template');
$mailTemplate->setReplyTo('[email protected]');
$mailTemplate->sendTransactional($templateId, $sender, $recipient, '', $vars, $storeId);
0
On

Reply-To is a standard email header: RFC 5322, section 3.6.2, and it has the form

"Reply-To:" address-list

So you can add it just as you would add a custom header:

$mail->addHeader("Reply-To", "[email protected]");

//Mage has addReplyTo() depending on version
$mail->addReplyTo('[email protected]', 'Name');

Also see Zend Documentation for Zend_Mail, which is what Magento uses.

1
On

So I manage to solve this by extend the MAILER class.

  • Arround line 74, function send(), you need to add $emailTemplate->setReplyTo($this->getReplyTo());

  • Also add this to functions to this same class:

    public function setReplyTo($replyto) { return $this->setData('replyto', $replyto); } public function getReplyTo() { return $this->_getData('replyto'); }

    • Lastly you just need to call this setReplyTo when you to set the replyTo (:P) on your extension.

      $mailer = Mage::getModel('core/email_template_mailer');

Thank you VladFR, but I wasn't able to figure out how to implement what you sugested.