I created a new module to overwrite the AddressController.php controller.
Here I make some changes and i receive some data from the customer address form. What I want to do now is to take all the data and send it via email.
My code for sending mail from controller looks like this:
$templateId = 17;
$emailTemplate = Mage::getModel('core/email_template')->load($templateId);
$mail = Mage::getModel('core/email');
$mail->setToName($customer->getId());
$email_template_variables = array(
'first' => $first_name,
'middlename' => $middle_name,
'lastname' => $last_name,
'company' => $company,
'telephone' => $phone,
'fax' => $fax,
'street' => $street[],
'city' => $city,
'country_id' => $contry,
'region' => $state
);
$mailSubject = 'Change billing address';
$from_email = "[email protected]";
$from_name = "testt";
$processedTemplate = $emailTemplate->getProcessedTemplate($email_template_variables);
$mail = Mage::getModel('core/email');
$mail->setToName('nume');
$mail->setTemplateParam($email_template_variables);
$mail->setToEmail('[email protected]');
$mail->setBody($processedTemplate);
$mail->setSubject($mailSubject);
$mail->setFromEmail($from_email);
$mail->setFromName($from_name);
$mail->setType('Html');
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
} catch (Exception $ex) {
Mage::getSingleton('core/session')->addError('Unable to send.');
}
Now my question is:
How can I create a new email template in my custom module and send those data? Because if I try to create a new email template from System > Transactional Email. it asks me to load a existing template. But I don't want this. I want to create a new one in my theme.
Can anybody help me with a solution?