0

This is my email sending code

if (isset($_POST['send'])) {
    $templateId = 9;
    $sendername = 'Call To Order';
    $senderemail = $_POST['email'];
    $sendermobile = $_POST['mobile'];
    $sender = Array('name' => $sendername,
        'email' => $senderemail);
    //recepient
    $toEmail = 'test@gmail.com';
    $vars = Array();
    $vars = Array('email' => $senderemail, 'mobile' => $sendermobile);
    $storeId = Mage::app()->getStore()->getId();
    $translate = Mage::getSingleton('core/translate');
    Mage::getModel('core/email_template')
            ->sendTransactional($templateId, $sender, $toEmail, $vars, $storeId);
    $translate->setTranslateInline(true);
}
?>

this is my transnational email template

Email: {{var email}}

Mobile: {{var mobile}}

And I am getting this into my email

enter image description here

2 Answers 2

0

Below definition of sendTransactional method :

/**
 * Send transactional email to recipient
 *
 * @param   int $templateId
 * @param   string|array $sender sneder informatio, can be declared as part of config path
 * @param   string $email recipient email
 * @param   string $name recipient name
 * @param   array $vars varianles which can be used in template
 * @param   int|null $storeId
 * @return  Mage_Core_Model_Email_Template
 */
public function sendTransactional($templateId, $sender, $email, $name, $vars=array(), $storeId=null)

As you can see $vars is fifth parameter.

You code should looks like that :

Mage::getModel('core/email_template')
        ->sendTransactional($templateId, $sender, $toEmail, 'recipient name' $vars, $storeId);
-2

Try to allow your variables :

System -> Permissions -> Variables -> Add new Variable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.