Posted By

snaidoo on 01/21/11


Tagged

magento


Versions (?)

Send TransactionalEmail


 / Published in: PHP
 

  1. <?php
  2. /**
  3. * $templateId can be set to numeric or string type value.
  4. * You can use Id of transactional emails (found in
  5. * "System->Trasactional Emails"). But better practice is
  6. * to create a config for this and use xml path to fetch
  7. * email template info (whatever from file/db).
  8. */
  9. const EMAIL_TEMPLATE_XML_PATH = 'customer/testemail/email_template';
  10. $templateId = Mage::getStoreConfig(EMAIL_TEMPLATE_XML_PATH);
  11.  
  12. $mailSubject = 'HI this is a test mail.';
  13.  
  14. /**
  15. * $sender can be of type string or array. You can set identity of
  16. * diffrent Store emails (like 'support', 'sales', etc.) found
  17. * in "System->Configuration->General->Store Email Addresses"
  18. */
  19. $sender = Array('name' => 'S. M. Asad Rahman',
  20. 'email' => '[email protected]');
  21.  
  22. /**
  23. * In case of multiple recipient use array here.
  24. */
  25. $email = '[email protected]';
  26.  
  27. /**
  28. * If $name = null, then magento will parse the email id
  29. * and use the base part as name.
  30. */
  31. $name = 'Asad Rahman';
  32.  
  33. $vars = Array();
  34. /* An example how you can pass magento objects and normal variables*/
  35. /*
  36. $vars = Array('customer'=>$customer,
  37. 'address' =>$address,
  38. 'varification_data'=>'fake data for example');*/
  39.  
  40. /*This is optional*/
  41. $storeId = Mage::app()->getStore()->getId();
  42.  
  43. $translate = Mage::getSingleton('core/translate');
  44. Mage::getModel('core/email_template')
  45. ->setTemplateSubject($mailSubject)
  46. ->sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
  47. $translate->setTranslateInline(true);
  48. ?>

Report this snippet  

You need to login to post a comment.