2

I want to send new register customer email with one variable generated by script.

I am trying using $customerObj->sendNewAccountEmail('confirmed'); Please tell

How I can send custom email template with variable?

I have created one custom email template 'new register email' in transactional emails with {{var myvar}}

4

More or less a few arrays to setup, I would suggest tacking onto an observer event (or a core rewrite, in which case you'll find the send function for customer registrations in the mage core customer folder!) to send your custom script out (there's a list of the observers available if you google!):

Declare the sender as an array:

$sender = Array('name'  => 'You',
        'email' => 'you@domain.com');

The recipient address, just literally needs to be a string, similarly to the mail subject.

$email = 'customer@customer.com';

Set your template id:

$templateId = 40;

And finally declare your custom variables to be sent along to the template:

$vars = Array('nameOfCustomer' => $customerName,
              'shippingDetails' => $shipping,
              'storeName' => $store_name,
              'storeURL' => $store_url,
              'orderId' => $orderId);

Followed up with the send function, i tend to just leave the $name as a null var:

$storeId = Mage::app()->getStore()->getId();
$translate  = Mage::getSingleton('core/translate');
Mage::getModel('core/email_template')
->setTemplateSubject($mailSubject)
->sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);

Then in your template call the var as literal for example:

{{var storeName}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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