Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
How can i send an email when user activates his account
<cms:if action='activate' >
<h1>Activate account</h1>

<cms:member_process_activation />

<cms:if k_success >

.. email at this point ..

<cms:set_flash name='success_msg' value='2' />
<cms:redirect k_page_link />
<cms:else />
<cms:show k_error />
</cms:if>
..
..
I have placed this code at the position you mentioned.
Code: Select all
                             <cms:php>
                        require_once('PHPMailer/PHPMailerAutoload.php');
                        $name=$_POST["member_displayname"];
                        $email=$_POST["member_email"];
                        $activation_key="<cms:show k_member_activation_link />";
                        $my_msg="hello";
                        $msg="hello";
                        $mail = new PHPMailer;
                        $mail->IsSMTP();
                        $mail->SMTPAuth = 1;
                        $mail->Host = "xxx.xxx.com";
                        $mail->SMTPSecure = "ssl";
                        $mail->Port =465;
                        $mail->Username = "contact@xxxx.com";
                        $mail->Password = "xxx";
                        $mail->SMTPDebug = 4;
                        $mail->SetFrom('contact@xxx.com', 'xxx');
                        $mail->AddReplyTo('contact@xxx.com', 'xxx');
                        $mail->Subject = "Welcome mail from xxxx";
                        $mail->AltBody = $my_msg."To view the HTML message, please use an HTML compatible email viewer!";
                        $mail->MsgHTML($msg);
                        $mail->AddAddress($email,$name);
                        if(!$mail->Send())
                        {
                        echo "Mailer Error: ".$mail->ErrorInfo;
                        echo $activation_key;
                        }
                        else
                        {
                        echo "Message sent!";
                        echo $activation_key;
                        }
                    </cms:php>


But the email is not being received by the user.
Try debugging by placing hard-coded values (instead of variables) for the email addresses.
See if the mail goes through then switch to using variables.
Email is delivered when using hard-coded values.
:) Then please see if the variables are really getting set. Perhaps they are empty.
Try placing a <cms:dump /> to get a list of all Couch variables available.

See, all this has nothing to do with Couch per se. It is plain debugging technique.
I used <cms:dump/> in the place but there is no variable which has user's email
I think the following should work
Code: Select all
<cms:php>
    require_once('PHPMailer/PHPMailerAutoload.php');
    $name='<cms:show k_member_title />';
    $email='<cms:show k_member_email />';
    ..
    ..

The 'k_member_title ' and 'k_member_email' are available at that point (<cms:dump_all /> will reveal them as they are in global context).

Does this help? Please let me know.
Its works now.
Thanks a lot for your help.
You are welcome :)
10 posts Page 1 of 1