title: Magento need to send custom account confirmation email to specific customer group
body: <p>I've been looking through files and scratching my head. Where is the function to send new account creation emails? And once I find it what variable would I use to refer to a particular customer group?</p>
  
  <p>EDIT 2/18
  Per the suggestion below I am looking at the Customer.php file and see the following function:</p>
  
  <pre><code> public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
      {
          $types = array(
              'registered'   =&gt; self::XML_PATH_REGISTER_EMAIL_TEMPLATE,  // welcome email, when confirmation is disabled
              'confirmed'    =&gt; self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
              'confirmation' =&gt; self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,   // email with confirmation link
          );
          if (!isset($types[$type])) {
              Mage::throwException(Mage::helper('customer')-&gt;__('Wrong transactional account email type'));
          }
  
          if (!$storeId) {
              $storeId = $this-&gt;_getWebsiteStoreId($this-&gt;getSendemailStoreId());
          }
  
          $this-&gt;_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
              array('customer' =&gt; $this, 'back_url' =&gt; $backUrl), $storeId);
  
          return $this;
      }
  </code></pre>
  
  <p>I assume I can set a different type in the $types array but how do I access the constant
  const XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity' to set a new type condition? I haven't yet figured out how to find xml paths.</p>
  
  <hr>
  
  <p>Edit 2/21</p>
  
  <p>I've copied the whole module file and renamed it and created it as my own module. I changed the following in the config file:</p>
  
  <pre><code>&lt;customer_create_account_email_template_dvm translate="label" module="customer"&gt;
                      &lt;label&gt;New account DVM&lt;/label&gt;
                      &lt;file&gt;account_new_dvm.html&lt;/file&gt;
                      &lt;type&gt;html&lt;/type&gt;
                  &lt;/customer_create_account_email_template_dvm&gt;
  </code></pre>
  
  <p>To add my template and also here second from bottom. </p>
  
  <pre><code>&lt;create_account&gt;
                  &lt;confirm&gt;0&lt;/confirm&gt;
                  &lt;default_group&gt;1&lt;/default_group&gt;
                  &lt;tax_calculation_address_type&gt;billing&lt;/tax_calculation_address_type&gt;
                  &lt;email_domain&gt;example.com&lt;/email_domain&gt;
                  &lt;email_identity&gt;general&lt;/email_identity&gt;
                  &lt;email_template&gt;customer_create_account_email_template&lt;/email_template&gt;
                  &lt;email_confirmation_template&gt;customer_create_account_email_confirmation_template&lt;/email_confirmation_template&gt;
                  &lt;email_register_template_dvm&gt;customer_create_account_email_register_template_dvm&lt;/email_register_template_dvm&gt;
                  &lt;email_confirmed_template&gt;customer_create_account_email_confirmed_template&lt;/email_confirmed_template&gt;
                  &lt;vat_frontend_visibility&gt;0&lt;/vat_frontend_visibility&gt;
              &lt;/create_account&gt;
  </code></pre>
  
  <p>Then added the constant to Customer.php</p>
  
  <pre><code>const XML_PATH_CONFIRM_EMAIL_TEMPLATE_DVM       = 'customer/create_account/email_confirmation_template_dvm';
  </code></pre>
  
  <p>and modified function:</p>
  
  <pre><code>public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
      {
  
          Mage::getSingleton('core/session', array('name'=&gt;'frontend')); 
          $session = Mage::getSingleton('customer/session');
  
          //Caitlin Havener
          //What Group do you belong to?
          if($session-&gt;isLoggedIn()) {
              $customerGroupID = $session-&gt;getCustomerGroupId();
              print("Customer Group ID is ". $customerID);
          } else {
              echo 'Not logged In';
          }
  
          //If you are DVM set your type
          if ($customerGroupID==5)
          {
              $type = 'dvm';
          }
  
          $types = array(
              'registered'   =&gt; self::XML_PATH_REGISTER_EMAIL_TEMPLATE,  // welcome email, when confirmation is disabled
              'confirmed'    =&gt; self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
              'confirmation' =&gt; self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,   // email with confirmation link
              'dvm' =&gt; self::XML_PATH_REGISTER_EMAIL_TEMPLATE_DVM,   // dvm new account email
          );
          if (!isset($types[$type])) {
              Mage::throwException(Mage::helper('customer')-&gt;__('Wrong transactional account email type'));
          }
  
          if (!$storeId) {
              $storeId = $this-&gt;_getWebsiteStoreId($this-&gt;getSendemailStoreId());
          }
  
          $this-&gt;_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
              array('customer' =&gt; $this, 'back_url' =&gt; $backUrl), $storeId);
  
          return $this;
      }
  </code></pre>
  
  <p>I tested it out and it does not work. As you can see I have some echos to trace, but I'm not sure how to directly debug this. I have Firebug but can't figure out how to use it. Any suggestions would be more than greatly appreciated. Would $session->isLoggedIn() evaluate false?</p>
  
  <p><strong>UPDATE 2/27/13_<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__
  @Meabed</strong> I'm trying to replicate what you are doing in blog post. I made a folder called CaitlinHavener, put DVMCustomer directory in it and an etc folder within that. I have config.xml inside of it:</p>
  
  <pre><code>&lt;template&gt;
              &lt;email&gt;
                  &lt;CaitlinHavener_DVMCustomer translate="label" module="mymodule"&gt;
                      &lt;label&gt;DVMCustomer Template&lt;/label&gt;
                      &lt;file&gt;custom/mytemplate.html&lt;/file&gt;
                      &lt;type&gt;html&lt;/type&gt;
                  &lt;/CaitlinHavener_DVMCustomer&gt;
              &lt;/email&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>and inside system.xml I have:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;config&gt;
      &lt;sections&gt;
          &lt;customer translate="label" module="mymodule"&gt;
              &lt;groups&gt;
                  &lt;custom_email translate="label"&gt;
                      &lt;label&gt;DVM Custom Template&lt;/label&gt;
                      &lt;frontend_type&gt;text&lt;/frontend_type&gt;
                      &lt;sort_order&gt;5&lt;/sort_order&gt;
                      &lt;show_in_default&gt;1&lt;/show_in_default&gt;
                      &lt;show_in_website&gt;0&lt;/show_in_website&gt;
                      &lt;show_in_store&gt;0&lt;/show_in_store&gt;
                      &lt;fields&gt;
                              &lt;exist_user_template translate="label"&gt;
                                  &lt;label&gt;DVM Custom Template&lt;/label&gt;
                                  &lt;frontend_type&gt;select&lt;/frontend_type&gt;
                                  &lt;source_model&gt;adminhtml/system_config_source_email_template&lt;/source_model&gt;
                                  &lt;sort_order&gt;3&lt;/sort_order&gt;
                                  &lt;show_in_default&gt;1&lt;/show_in_default&gt;
                                  &lt;show_in_website&gt;1&lt;/show_in_website&gt;
                                  &lt;show_in_store&gt;1&lt;/show_in_store&gt;
                              &lt;/exist_user_template&gt;
                      &lt;/fields&gt;
                  &lt;/custom_email&gt;
              &lt;/groups&gt;
          &lt;/customer&gt;
      &lt;/sections&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>I created a modules xml called CaitlinHavener_DVMCustomer.xml and put it in the modules folder: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;config&gt;    
      &lt;modules&gt;
          &lt;CaitlinHavener_DVMCustomer&gt;
              &lt;active&gt;true&lt;/active&gt;
              &lt;codePool&gt;local&lt;/codePool&gt;
          &lt;/CaitlinHavener_DVMCustomer&gt;
      &lt;/modules&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>When I go to system>config>advanced I can see that the system registers the module but when I go to system>transactional emails I do not see it there or when I create new template and select "load template". </p>
  
  <p>Do you see what I am doing wrong?</p>