D
D
Dim Boy2015-11-30 21:58:59
PHP
Dim Boy, 2015-11-30 21:58:59

How to add html code to send mail?

There is this code:

if(pligg_validate()){
        $encode=md5($_POST['email'] . $user->karma .  $user->username. pligg_hash().$main_smarty->get_config_vars('PLIGG_Visual_Name'));

        $domain = $main_smarty->get_config_vars('PLIGG_Visual_Name');			
        $validation = my_base_url . my_pligg_base . "/validation.php?code=$encode&uid=".urlencode($user->username)."&email=".urlencode($_POST['email']);
        $str = $main_smarty->get_config_vars('PLIGG_PassEmail_verification_message');
        eval('$str = "'.str_replace('"','\"',$str).'";');
        $message = "$str";

        if(phpnum()>=5)
          require("libs/class.phpmailer5.php");
        else
          require("libs/class.phpmailer4.php");
        $mail = new PHPMailer();
        $mail->From = $main_smarty->get_config_vars('PLIGG_PassEmail_From');
        $mail->FromName = $main_smarty->get_config_vars('PLIGG_PassEmail_Name');
        $mail->AddAddress($_POST['email']);
        $mail->AddReplyTo($main_smarty->get_config_vars('PLIGG_PassEmail_From'));
        $mail->IsHTML(false);
        $mail->Subject = $main_smarty->get_config_vars('PLIGG_PassEmail_Subject_verification');
        $mail->Body = $message;
        $mail->CharSet = 'utf-8';

#print_r($mail);					
        if(!$mail->Send())
          return false;
        $savemsg = $main_smarty->get_config_vars("PLIGG_Visual_Register_Noemail").' '.sprintf($main_smarty->get_config_vars("PLIGG_Visual_Register_ToDo"),$main_smarty->get_config_vars('PLIGG_PassEmail_From'));
      }

PLIGG_PassEmail_verification_messageis an ordinary registration message in a language file.
"Hello $username,\\r\\n\\r\\nWe\'ve sent you this email because you signed up for a new account on $domain. If you didn\'t mean to do that, you can safely ignore this message.\\r\\n\\r\\nVisit this link to activate your account:\\r\\n $validation \\r\\n\\r\\nYour Password is $password \\r\\n\\r\\nIf clicking the link doesn\'t work, copying the complete link address into your browser.\\r\\nStill having trouble? Contact us at $contactmail\\r\\n\\r\\nAfter activation of your account, you can login at $my_base_url$my_pligg_base\\r\\n\\r\\nEnjoy!\\r\\n\\r\\nThe Administrator"

Where is the right place to add this html code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nelson, 2015-11-30
@twix007

Instead
of $mail->IsHTML(false);
$mail->Body = $message;
Use
$mail->IsHTML(true);
$mail->MsgHTML( $message );
The HTML code you specified must be in the $message variable

D
Dim Boy, 2015-12-01
@twix007

nelson : according to your first instruction, I tried to redo another piece:

if($user){
        $username = $user->user_login;
        $salt = substr(md5(uniqid(rand(), true)), 0, SALT_LENGTH);
        $saltedlogin = generateHash($user->user_login);
  
        $to = $user->user_email;
        $subject = $main_smarty->get_config_vars("PLIGG_PassEmail_Subject");
      
        $times= time();		
            
        $body = sprintf($main_smarty->get_config_vars("PLIGG_PassEmail_Body"),$main_smarty->get_config_vars("PLIGG_Visual_Name")); 
        $body .="\n \n";
        $body .= $my_base_url . $my_pligg_base . '/recover.php?id=' . base64_encode($username). '&n=' . time();
  
        $headers = 'From: ' . $main_smarty->get_config_vars("PLIGG_PassEmail_From") . "\r\n";
        $headers .= "Content-type: text/html; charset=utf-8\r\n";
  
      
        if(phpnum()>=5)
            require("libs/class.phpmailer5.php");
        else
            require("libs/class.phpmailer4.php");	
        
        $mail = new PHPMailer();
        $mail->From = $main_smarty->get_config_vars('PLIGG_PassEmail_From');
        $mail->FromName = $main_smarty->get_config_vars('PLIGG_PassEmail_Name');
        $mail->AddAddress($to);
        $mail->AddReplyTo($main_smarty->get_config_vars('PLIGG_PassEmail_From'));
        $mail->IsHTML(false);
        $mail->Subject = $subject;
        $mail->CharSet = 'utf-8';
        $mail->Body = $body;

my version and even the page doesn't work....
if($user){
        $username = $user->user_login;
        $salt = substr(md5(uniqid(rand(), true)), 0, SALT_LENGTH);
        $saltedlogin = generateHash($user->user_login);
  
        $to = $user->user_email;
        $subject = $main_smarty->get_config_vars("PLIGG_PassEmail_Subject");
      
        $times= time();		
          
        $recoverpass = my_base_url . my_pligg_base . "/recover.php?id=" .base64_encode($username). "&n=" .time();
        $resetpass = "<div ......</div>"
        $headers = 'From: ' . $main_smarty->get_config_vars("PLIGG_PassEmail_From") . "\r\n";
        $headers .= "Content-type: text/html; charset=utf-8\r\n";
  
      
        if(phpnum()>=5)
            require("libs/class.phpmailer5.php");
        else
            require("libs/class.phpmailer4.php");	
        
        $mail = new PHPMailer();
        $mail->From = $main_smarty->get_config_vars('PLIGG_PassEmail_From');
        $mail->FromName = $main_smarty->get_config_vars('PLIGG_PassEmail_Name');
        $mail->AddAddress($to);
        $mail->AddReplyTo($main_smarty->get_config_vars('PLIGG_PassEmail_From'));
        $mail->IsHTML(true);
        $mail->Subject = $subject;
        $mail->CharSet = 'utf-8';
        $mail->Body = $resetpass;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question