9 Replies Latest reply on Apr 1, 2010 6:57 PM by Albert S.

    Activation Email Dying Silently

    ThirdGenBruin

      My problem seems pretty basic.  I'm using the registration wizard and selecting both the "welcome email" and "activation email" options.  The welcome email comes through, but the activation email dies silently.  I'm in debug mode and no errors are generated.  All of the rest of the functionality works, including the redirect on success.  The user is being created in the database and the random key is being generated.  It is just the email that is not being sent.
      At first I thought it might be because my data formats in my database weren't correct, but I saw Guenter's tutorial and set my data formats to be the same as his.  That didn't help.
      I'm using MAMP (and therefore Postfix) on Mac OS X.  I've tried using the PHP 4 and PHP 5 option.  Doesn't seem to matter.
      Any ideas what might be going on?  Any help is appreciated.

        • 1. Re: Activation Email Dying Silently
          Albert S. Level 3

          Hi,

          Any chance of getting a code snippet of the trigger?

          • 2. Re: Activation Email Dying Silently
            ThirdGenBruin Level 1

            I'm guessing you're asking for the Send Email (trigger_ActivationEmail) trigger?  If so:

             

            //start Trigger_WelcomeEmail trigger

            //remove this line if you want to edit the code by hand

            function Trigger_WelcomeEmail(&$tNG) {

              $emailObj = new tNG_Email($tNG);

              $emailObj->setFrom("{KT_defaultSender}");

              $emailObj->setTo("{email}");

              $emailObj->setCC("");

              $emailObj->setBCC("");

              $emailObj->setSubject("Welcome");

              //FromFile method

              $emailObj->setContentFile("includes/mailtemplates/welcome.html");

              $emailObj->setEncoding("ISO-8859-1");

              $emailObj->setFormat("HTML/Text");

              $emailObj->setImportance("Normal");

              return $emailObj->Execute();

            }

            //end Trigger_WelcomeEmail trigger

             

            //start Trigger_ActivationEmail trigger

            //remove this line if you want to edit the code by hand

            function Trigger_ActivationEmail(&$tNG) {

              $emailObj = new tNG_Email($tNG);

              $emailObj->setFrom("{KT_defaultSender}");

              $emailObj->setTo("{email}");

              $emailObj->setCC("");

              $emailObj->setBCC("");

              $emailObj->setSubject("Activation");

              //FromFile method

              $emailObj->setContentFile("includes/mailtemplates/activate.html");

              $emailObj->setEncoding("ISO-8859-1");

              $emailObj->setFormat("HTML/Text");

              $emailObj->setImportance("Normal");

              return $emailObj->Execute();

            }

            //end Trigger_ActivationEmail trigger

             

            -----------------------

             

            I included the welcome trigger just so you could compare.  The welcome trigger works fine and the activation email dies silently.  It doesn't matter if I change the order of the triggers (i.e. put activation before welcome).  The welcome email still sends and the activation doesn't.

             

            Thanks for taking a look.

             

            Chris

            • 3. Re: Activation Email Dying Silently
              Albert S. Level 3

              Can you also send the RegisterTriggers?

              • 4. Re: Activation Email Dying Silently
                ThirdGenBruin Level 1

                Here are the registration triggers.  I've included the captcha stuff just in case as well, but I've tried it with and without captcha and that doesn't effect it.

                 

                // Register triggers

                $userRegistration->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");

                $userRegistration->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);

                $userRegistration->registerConditionalTrigger("{POST.password} != {POST.re_password}", "BEFORE", "Trigger_CheckPasswords", 50);

                $userRegistration->registerTrigger("AFTER", "Trigger_ActivationEmail", 40);

                $userRegistration->registerTrigger("AFTER", "Trigger_WelcomeEmail", 40);

                $userRegistration->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");

                $userRegistration->registerTrigger("BEFORE", "CheckCaptcha", 10);

                // Add columns

                $userRegistration->setTable("users_tbl");

                $userRegistration->addColumn("username", "STRING_TYPE", "POST", "username");

                $userRegistration->addColumn("password", "STRING_TYPE", "POST", "password");

                $userRegistration->addColumn("email", "STRING_TYPE", "POST", "email");

                $userRegistration->addColumn("schoolID", "NUMERIC_TYPE", "POST", "schoolID");

                $userRegistration->setPrimaryKey("id", "NUMERIC_TYPE");

                 

                // Execute all the registered transactions

                $tNGs->executeTransactions();

                 

                // Get the transaction recordset

                $rsusers_tbl = $tNGs->getRecordset("users_tbl");

                $row_rsusers_tbl = mysql_fetch_assoc($rsusers_tbl);

                $totalRows_rsusers_tbl = mysql_num_rows($rsusers_tbl);

                 

                // Captcha Image

                $captcha_id_obj = new KT_CaptchaImage("captcha_id_id");

                 

                // Captcha Image

                $captcha_id_obj = new KT_CaptchaImage("captcha_id_id");

                • 5. Re: Activation Email Dying Silently
                  Albert S. Level 3

                  Well I don't see anything wrong with the code that sticks out. Have you tried removing the welcome email to see if the activation email then works?

                  Basically to see if one works regardless of which one it is.

                   

                  comment out this line...

                  // $userRegistration->registerTrigger("AFTER",  "Trigger_WelcomeEmail", 40);

                   

                   

                  or change this to change the priority order of the emails...

                   

                  $userRegistration->registerTrigger("AFTER",  "Trigger_ActivationEmail", 40);

                  $userRegistration->registerTrigger("AFTER",  "Trigger_WelcomeEmail", 40);

                   

                  to...

                   

                  $userRegistration->registerTrigger("AFTER",  "Trigger_ActivationEmail", 40);

                  $userRegistration->registerTrigger("AFTER",  "Trigger_WelcomeEmail", 50);

                   

                  Let me know...

                  • 6. Re: Activation Email Dying Silently
                    ThirdGenBruin Level 1

                    I've tried just one or the other and the welcome always works and the activation email never works.

                     

                    My hypothesis is that it is perhaps something is going on inside the activation trigger, but I don't know how to troubleshoot it.  I haven't changed anything in the tNG files, not even the activation email template.

                     

                    Thanks for looking into this for me.

                    • 7. Re: Activation Email Dying Silently
                      Albert S. Level 3

                      Heres a couple other things to try. Check your spam filters make sure that the email is not getting trapped, cornered and beaten to death for being spam . Also try changing it from a templated email to a normal email trigger with no template. See if any of those help shed some light on the problem.

                      Looking over your triggers I see nothing wrong.

                      1 person found this helpful
                      • 8. Re: Activation Email Dying Silently
                        ThirdGenBruin Level 1

                        Now we're getting somewhere!

                         

                        Okay, so I feel like an idiotic for not checking the spam filter, but (thankfully for my ego) that isn't the problem.

                         

                        Based on your other suggestion, I changed the "Body" drop down in the "Main" tab of the Send Email behavior to "Write Content" instead of "Retrieve content from file."  I just put in some dummy text and voila, both the Welcome email and Activation Email sent successfully.  Yeah!  Of course, that doesn't solve the problem yet, but I feel like we're making progress.  Here is the content of the activation email template:

                         

                        <html>

                        <head>

                        <style>

                        .heading {border: solid 1px #000000;}

                        </style>

                        </head>

                        <body>

                        <h3 class="heading">Account activation.</h3>

                        <p>Hello,</p>

                        <p>You received this message because you registered to our website. You need to activate your account first, in order to log in to our website.</p>

                        <p>Your username is <strong>{kt_login_user}</strong></p>

                        <p>To activate your account, click on the following link:<br>

                        <a href="{kt_activation_page}" target="_blank">{kt_activation_page}</a></p>

                        <p>To log in to our website, click on the following link:<br>

                        <a href="{kt_login_page}" target="_blank">{kt_login_page}</a></p>

                        <p><strong>Site Owner</strong></p>

                        </body>

                        </html>

                         

                        Again, I haven't changed anything.  This is the default template.  So I decided to try to figure out what in the template was breaking it.  First, I deleted all the variables from the template and the email sent correctly.  I then began testing the variables one by one to see if they were causing a problem.  It turns out the kt_login_page is the problem.  When I remove that, everything works correctly, including the activation link.  I'm now going to try to figure out why that is.

                         

                        The login page on my site works fine and is a valid URL.  If worse comes to worse, I can just delete that link.  I really just want them clicking on the activation email at that point any way.

                        • 9. Re: Activation Email Dying Silently
                          Albert S. Level 3

                          Glad to hear it.

                           

                          Make sure that the login page is defined in the control panel.