Here is how I'm sending emails from my multi-site magento 1.9.2.4, this function is called by a cron job & working fine to send emails.
Everything is working fine but all of the emails templates (there are different templates for different wesbsites/stores) have store url of admin. I don't know why {{store url=""}}"
& "{{config path="web/secure/base_url"}}
are returning admin store url instead of the Store Id I'm setting to template
public function sendEmail($templateId, $vars,$storeId ,$name, $email)
{
try {
$from_email = Mage::getStoreConfig('trans_email/ident_general/email',$storeId); //fetch sender email Admin
$from_name = Mage::getStoreConfig('trans_email/ident_general/name',$storeId); //fetch sender name Admin
$emailTemplate = Mage::getModel('core/email_template');
$emailTemplate->setStoreId($storeId);
$emailTemplate->load($templateId);
$emailTemplate->setSenderName($from_name);
$emailTemplate->setSenderEmail($from_email);
foreach ($vars as $key => $value) {
$emailtemplateVariables[$key] = $value;
}
$result = $emailTemplate->send($email, $name, $emailtemplateVariables);
Mage::log("Template Id : ".$templateId." send result : ".$result,null,"T-Emails.log");
} catch(Exception $ex) {
Mage::log($ex->getMessage(), null,"T-Emails.log");
}
return $result;
}
Thanks
$emailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $storeId));