2

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.

Community
  • 1
  • 1
Jóni
  • 364
  • 1
  • 3
  • 16

3 Answers3

3

There’s no need to extend any class.

Just use:

$mailTemplate = Mage::getModel('core/email_template');
$mailTemplate->setReplyTo('test@example.com');
$mailTemplate->sendTransactional($templateId, $sender, $recipient, '', $vars, $storeId);
Daniel Kratohvil
  • 1,253
  • 15
  • 14
2

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.

Jóni
  • 364
  • 1
  • 3
  • 16
1

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", "reply.to@example.com");

//Mage has addReplyTo() depending on version
$mail->addReplyTo('email@example.com', 'Name');

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

Collin Anderson
  • 14,787
  • 6
  • 68
  • 57
VladFr
  • 816
  • 1
  • 10
  • 18