1

I followed the tutorial below. I'm trying to send an email to the administrator when a new user signs up. The email is sending it's just sending when I hit the page not after filling out the information. How can I only have it send after they fill out the registration form??

http://inchoo.net/magento/magento-custom-emails/#comments

In my config.xml

<email>
  <custom_email_template1 module="SampleModule1">
    <label>ActiveCodeline custom email module</label>
    <file>activecodeline_custom_email1.html</file>
    <type>html</type>
  </custom_email_template1>
</email>

In App/local/en_us/template/email/activecodeline_custom_email1.html

<div>
<h1>ActiveCodeline custom email example by Branko Ajzele</h1>
<p>Hi there {{var myvar1}} {{var myvar2}} from {{var myvar3}}. This is just some example template to test custom email module.</p>
</div>

and lastly in my register.phtml I put this at the bottom.

<?

    $emailTemplate = Mage::getModel('core/email_template')->loadDefault('custom_email_template1');

    //Getting the Store E-Mail Sender Name.
    $senderName = 'billa';

    //Getting the Store General E-Mail.
    $senderEmail = 'email@email.com';

    //Variables for Confirmation Mail.
    $emailTemplateVariables = array();
    $emailTemplateVariables['myvar1'] = 'Email Address';
    $emailTemplateVariables['myvar2'] = 'Ajzele';
    $emailTemplateVariables['myvar3'] = 'ActiveCodeline';

    //Appending the Custom Variables to Template.
    $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);

    //Sending E-Mail to Customers.
    $mail = Mage::getModel('core/email')
    ->setToName('bilaa')
    ->setToEmail('email@email.com')
    ->setBody($processedTemplate)
    ->setSubject('Subject : A New Customer Has Signed Up')
    ->setFromEmail('email@email.com')
    ->setFromName('New Customer Notification')
    ->setType('html');
    try{
    //Confimation E-Mail Send
    $mail->send();
    }
    catch(Exception $error)
    {
    Mage::getSingleton('core/session')->addError($error->getMessage());
    return false;
    }
?>
  • are you need to send email to admin after fill up all form fields or only First Name, Last Name & Email? – Abdul Dec 24 '15 at 4:28
  • @Abdul I want to eventually include all fields but I was going to start by trying to get it to work with the basics first. – user3330820 Dec 24 '15 at 14:08

Your Answer

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

Browse other questions tagged or ask your own question.