Hi, My site is in French and English. At the renewal time, I would like that the system, send emails to members "according to their language preference in user info" . In the file cron.php, the system send an email for each ads to be renew. I used the extra3 field in the User View Setting for the language. I have a template named "hobby_en" for english user and a template named "hobby_fr" for french user. I made an english email html template in the hobby_en/emails/html/renewal.tpl and in french hobby_fr/emails/html/renewal.tpl Now here is my problem. I know the Var $content content the template renewal.tpl but I don't know how to put the path of the template to let the system know in which language to send them. PHP: if($checkoutSettings['renewal']=='Y') { $renewalDays=$checkoutSettings['renewalDays']; $expiration = mktime(0,0,0,date("m"),date("d")+$renewalDays,date("Y")); $expiration = strftime("%Y-%m-%d",$expiration); $sSQL = "SELECT p.id,p.owner,p.orderID,p.title,p.dateadded, u.email,u.firstname,u.lastname,u.extra3 FROM ".PREFIX."listings AS p INNER JOIN ".PREFIX."users AS u ON p.owner=u.id WHERE p.expiration <= '".$expiration."' AND notified='N' AND display='Y'"; $result=$db->query($sSQL); $numrows = $result->size(); while($rs=$result->fetch()) { $id=$rs['id']; $owner=$rs['owner']; $title=safeStripSlashes($rs['title']); $datelisted=$rs['dateadded']; $to=$rs["email"]; $vars['title']=$title; $vars['oID']=$rs['orderID']; $vars['firstname']=$rs['firstname']; $vars['lastname']=$rs['lastname']; if($rs['extra3']=='fr') { Path in french; } else { Path in english; } $msg=$Mailer->sendMail($to, $content, $vars); if($msg==TRUE) { $sSQL="UPDATE ".PREFIX."listings SET notified='Y' WHERE id=".$id." AND owner='".$owner."'"; $db->query($sSQL); } else { $cronlog .= $msg."<br />"; } } $cronlog = "Renewals Sent: ".$numrows."<br />"; } Do you have any idea?
I tried this: I received an email with this error: The emails/html/ before the Path come from the function sendMail: PHP: function sendMail($to, $content, $vars, $lang) { global $Core, $class_tpl; $this->AddAddress($to); $this->AddBCC("[email protected]"); // Hobby Classified envoi une copie de tous les emails du client à admin if(!empty($vars['fromemail'])){ $this->From=$vars['fromemail']; }if(!empty($vars['name'])) { $this->FromName=$vars['name']; } /* Hobby Classified ajout pour envoie copie de email nouveau membre if(!empty($vars['bcc'])) { $this->AddBCC=$vars['bcc']; } // Hobby Classified fin */ foreach($vars as $key => $value) { //loop through the results and assign to the template $class_tpl->assign($key, safeStripSlashes($value)); } if($Core->settings['mailHTML']=="Y") { $this->AltBody = $class_tpl->fetch('emails/text/'.$content); $this->Body = $class_tpl->fetch('emails/html/'.$content); $this->IsHTML(TRUE); } else { $this->Body = $class_tpl->fetch('emails/text/'.$content); $this->IsHTML(FALSE); } $this->Subject = $class_tpl->get_template_vars('subject'); if($this->Send()) { $this->ClearAllRecipients(); return TRUE; } else { return "Message was not sent <br />Mailer Error: " . $this->ErrorInfo; } }
Perhaps, it would be easier to simply place your french renewal email template in the administration assigned email template folder and call it something like renewal_fr.tpl. Then $content='renewal_fr.tpl'; That way in the code further down, you don't have to worry about the path, because the file is where it is already looking for the $content assigned name.