I have following custom e-mail templates and want to send them to particular customer.
My magento function as follows but fails to get relevant e-mail template.
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('Newsletter subscription success new');
$mail = Mage::getModel('core/email');
$mail->setToName('John Customer');
$mail->setToEmail('exa@gmail.com');
$mail->setBody($emailTemplate);
$mail->setSubject('The Subject');
$mail->setFromEmail('my@my.com');
$mail->setFromName("Your Name");
$mail->setType('text');// You can use 'html' or 'text'
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
$this->_redirect('');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
$this->_redirect('');
}
How I get the relevant e-mail template by name?
Best Answer
Here is the answer for your question.
Try with following full code