Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
I want to edit the mail that is sent for providing activation link to newly registered member.
I want to use phpmailer to send that email.
How can i do that?
Hi,

This is discussed in the docs on 'members' module - viewtopic.php?f=5&t=8063

Please see point no. 4 below 'Usage'.

Hope it helps.
If i disable send_mail, then how can i mail activation key to the user?
We are not disabling send_mail - just asking cms:member_process_registration_form tag not to automatically send the email (which it does by default).

Please take a look at the pseudo-code below.
Notice how after we set _send_mail='0' (thus not sending the automatic email), we are sending the mail ourselves in the very next block of code using cms:send_mail
<cms:member_process_registration_form
_send_mail='0'
/>

<cms:if k_success >
<cms:send_mail ...

...
<cms:set_flash name='success_msg' value='1' />
<cms:redirect k_page_link />
</cms:if>

In your case, you'll use phpmailer at the highlighted spot.

A lot many variables are made available for you to use in the email at that spot.
To see those, remove <cms:redirect k_page_link /> (so that the page does not refresh) and place <cms:dump /> in its place.
Register a user and you'll see all the data that you can use in your email.

Hope this helps.
I have added the following code.
Code: Select all
 <cms:member_process_registration_form
                       _send_mail='0'
                   
                    />
                   
                    <cms:if k_success >
                   
                    <cms:php>
require_once('PHPMailer/PHPMailerAutoload.php');
$name=$_POST["member_displayname"];
$email=$_POST["member_email"];
$my_msg="Welcome".$name." we sent this message to your email ".$email." "."<cms show:  k_member_activation_link />"." good";
$msg="Welcome".$name." we sent this message to your email ".$email;
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPAuth = 1;
$mail->Host = "smtp.mandrillapp.com";
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Username = "xxxxx@gmail.com";
$mail->Password = "xxxx";
$mail->SMTPDebug = 4;
$mail->SetFrom('xxxx@gmail.com', 'xxxx');
$mail->AddReplyTo('xxxx@gmail.com', 'xxx');
$mail->Subject = "Welcome mail from xxx";
$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;
}
else
{
echo "Message sent!";
}
</cms:php>
                        <cms:set_flash name='success_msg' value='1' />
                        <cms:dump />
                    </cms:if>


I am able to send mail to user.
But not able to use any variable that is shown in <cms:dump/>.
(e.g. "k_member_activation_link").
Used the k_member_activation_link as :

$activation_key=<cms:show k_member_activation_link />;

getting error


Parse error: syntax error, unexpected ':' in C:\xampp\htdocs\couch\tags.php(2420) : eval()'d code on line 5
Please try using double-quotes around the Couch statement -
Code: Select all
$activation_key="<cms:show k_member_activation_link />";

Does it help?
Yeah! It works now.
Thanks a lot :D
8 posts Page 1 of 1