Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to send custom new account email template? 
 
jjfattz
Jr. Member
 
Total Posts:  14
Joined:  2012-11-21
 

I’m using an extension that automatically creates an account for guests who checkout, and I would like to send them a different email (instead of the “new account” email).  I’ve created the new template in transactional emails, and I know exactly where to place the code to send the email upon guests checking out.  I just don’t know how to do it.

My email template closely resembles the new account template.  It includes the first name, last name, email, and password variables in the template.  So the email that I send will need to be populated with this data.  Please let me know if you need any more info.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jjfattz
Jr. Member
 
Total Posts:  14
Joined:  2012-11-21
 

Well, I ended up figuring it out myself, so I figured I’d post my findings in case anyone else needed the same info.

Here is the basic code that I used to send a transactional email I created called “new_account_from_guest”.

// get the email template by name
$template Mage::getModel('core/email_template') ->loadByCode('new_account_from_guest')->getTemplateId();

// create the sender array containing the store name and email
$sender  = array(
    
'name' => Mage::getStoreConfig('trans_email/ident_support/name'Mage::app()->getStore()->getId()),
    
'email' => Mage::getStoreConfig('trans_email/ident_support/email'Mage::app()->getStore()->getId())
);

// customers email gathered previously
$customerEmail $email;

// customers name gathered previously
$customerName $firstname." ".$lastname;

// create the order object based on the orders ID, which was gathered previously
$order Mage::getModel('sales/order')->load($order_id);

// create our vars for our email, $customer object created previously
$vars = Array( 'customer'=> $customer'order' => $order );

// send the email using the default store
Mage::getModel('core/email_template')->sendTransactional($template$sender$customerEmail$customerName$vars);
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top