Question

Je veux envoyer un nouveau courrier électronique client registre avec une variable générée par script.

Je suis en train utilisant $customerObj->sendNewAccountEmail('confirmed'); S'il vous plaît dire

Comment puis-je envoyer modèle de courriel personnalisé avec la variable?

J'ai créé un modèle de courrier électronique personnalisés 'new register email' dans les emails transactionnels avec {{var myvar}}

Était-ce utile?

La solution

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}}
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top