1
anna85
Xoops & Mail good reference ?
  • 2008/6/28 18:41

  • anna85

  • Just popping in

  • Posts: 47

  • Since: 2008/6/19


Hi,

Any good link on XOOPS core function and mail related reference ? I want to create a tpl file.

Tried search and couldn't find any good reference around.

Any help ??

Best regards
Xoopsuser

2
hervet
Re: Xoops & Mail good reference ?
  • 2008/7/6 17:25

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4



3
anna85
Re: Xoops & Mail good reference ?
  • 2008/7/7 18:06

  • anna85

  • Just popping in

  • Posts: 47

  • Since: 2008/6/19


Hi,

Thanks for your reply. I am testing on MXdirectory and trying to use $xoopsMailer->multimailer->IsHTML(true); and its not working on the contact.php ?

Do you have any idea why ??
Thanks....

Anna85
xoopsuser

4
hervet
Re: Xoops & Mail good reference ?
  • 2008/7/7 18:22

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


show us your code

5
anna85
Re: Xoops & Mail good reference ?-isHTML ?true
  • 2008/7/8 18:20

  • anna85

  • Just popping in

  • Posts: 47

  • Since: 2008/6/19


I pull this code from contact.php.

$xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$xoopsConfig['language'].'/mail_template/');
$xoopsMailer->setTemplate($thistemplate);

$xoopsMailer->assign('SNAME', $sname); //assign some vars for mail template
$xoopsMailer->assign('SEMAIL', $semail);
$xoopsMailer->assign('SUBJECT', $subject);
$xoopsMailer->assign('FRNAME', $frname);
$xoopsMailer->assign('FREMAIL', $fremail);
$xoopsMailer->assign('X_ADMINMAIL', $xadminmail);
$xoopsMailer->assign('X_SITENAME', $xsitename);
$xoopsMailer->assign('X_SITEURL', $xsiteurl);
$xoopsMailer->assign('X_LINK', $linkurl);
$xoopsMailer->assign('X_LINK_TITLE', $linktitle);
$xoopsMailer->assign('BODY', $body);
$xoopsMailer->multimailer->isHTML(true);

Its not working, any idea why? I am trying to give output as html email page, but its give code as html code with
etc..etc.

And without the $xoopsMailer->multimailer->isHTML(true); its works well as plain text.

Thanks for your help.Please help me.

Best regards
Xoopsuser

6
anna85
Re: Xoops & Mail good reference ?Limited Labelform ?
  • 2008/7/8 23:47

  • anna85

  • Just popping in

  • Posts: 47

  • Since: 2008/6/19


Hi,

I crosschecked on xoopsformlabel and its don't have any HTML enable. Do we need to code ourselves ? Anyone tried before...??

Just caption, value...

Your knowledge on this topic greatly appreciated.

Best regards
Xoopsuser

7
hervet
Re: Xoops & Mail good reference ?Limited Labelform ?
  • 2008/7/9 6:32

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


In my version of xDirectory I don't have a contact form but I suppose that your code translate html code (in the $body variable) into html entities.
That is to say that < and > become < >

Try to do a var_dump($body) to see its exact content

8
anna85
Re: Xoops & Mail good reference ?Limited Labelform ?
  • 2008/7/9 7:16

  • anna85

  • Just popping in

  • Posts: 47

  • Since: 2008/6/19


Hi hervet,

I am using Mxdirectory. I added wyswygtextarea.php to capture the pretty html.So i assure that where html code came from. But When I add the $xoopsMailer->multimailer->isHTML(true); under the contact.php, the whole email changed to html code.

I tried var_dump($body); just after above code and it makes no difference.

Please help me !!

Best regards
Xoopsuser
Singapore

9
hervet
Re: Xoops & Mail good reference ?
  • 2008/7/9 7:56

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Can you specify your XOOPS version and publish here the full code of your page ?

10
anna85
Re: Xoops & Mail good reference ?
  • 2008/7/9 10:20

  • anna85

  • Just popping in

  • Posts: 47

  • Since: 2008/6/19


Hervet,

Thanks for time.

I am using XOOPS 2.016 and I have installed a number of modules like job listing . I managed to change all the HTML enabled the same code ---> $xoopsMailer->multimailer->isHTML(true),but not with MXdirectory.



//returned vars
include_once("header.php");
include_once(XOOPS_ROOT_PATH."/header.php");
if ( file_exists("language/".$xoopsConfig['language']."/main.php") ) {
include_once "language/".$xoopsConfig['language']."/main.php";
} else {
include_once "language/english/main.php";
}

include_once XOOPS_ROOT_PATH."/class/module.errorhandler.php";
include "include/securitycheck.php";
//include "include/functions.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";

$myts =& MyTextSanitizer::getInstance();
//Consumer to Business
function ctob(){
global $xoopsConfig, $_GET, $xoopsDB, $myts, $meta;

global $xoopsModuleConfig, $_REQUEST, $xoopsDB, $myts, $meta, $xoopsUser;

$id = ( isset($_REQUEST['id']) )? $_REQUEST['id'] : null ;
$lid = ( isset($_REQUEST['lid']) )? $_REQUEST['lid'] : null ;
$op = ( isset($_REQUEST['op']) )? $_REQUEST['op'] : null ;
$sender = ( isset($_REQUEST['sender']) )? $_REQUEST['sender'] : null ;
$subject = ( isset($_REQUEST['subject']) )? $_REQUEST['subject'] : null ;
$body = ( isset($_REQUEST['body']) )? $_REQUEST['body'] : null ;
$xsname = ( isset($_REQUEST['sname']) )? $_REQUEST['sname'] : null ;
$xsemail = ( isset($_REQUEST['semail']) )? $_REQUEST['semail'] : null ;
$frname = ( isset($_REQUEST['frname']) )? $_REQUEST['frname'] : null ;
$fremail = ( isset($_REQUEST['fremail']) )? $_REQUEST['fremail'] : null ;

$result = $xoopsDB->query("SELECT title, email FROM ".$xoopsDB->prefix("xdir_links")." WHERE lid = '$lid'");
list($linktitle, $email) = $xoopsDB->fetchRow($result);

//may need 2.2 changes here due to u.n. conventions

if($xoopsUser) {
$xsname =$xoopsUser->getVar("uname");
$xsname = ($xsname == "") ? $xoopsUser->getVar("name") : $xsname ;

$xsemail =$xoopsUser->getVar("email");
}

$ctobform = new XoopsThemeForm(_MD_EMAILC.' '._MD_SITETITLE.' '.$linktitle, 'ctobform', $_SERVER['PHP_SELF'].'?op=sendit', 'POST');
$ctobform->addElement(new XoopsFormLabel(_MD_SUBJECT, $linktitle));
$ctobform->addElement(new XoopsFormText(_MD_YOUR.' '._MD_NAME , 'sname', 50, 100, $xsname),true);
$ctobform->addElement(new XoopsFormText(_MD_YOUR.' '._MD_EMAILC , 'semail', 50, 50, $xsemail),true);

include_once(XOOPS_ROOT_PATH."/class/wysiwyg/formwysiwygtextarea.php");
$ctobform->addElement(new XoopsFormWysiwygTextArea(_MD_MESSAGE, 'body', 5, 50));
$regtray = new XoopsFormElementTray('','','');

if ( empty($xoopsUser) && $xoopsModuleConfig['captcha_anon'] ) {
$gd = ( extension_loaded('gd') ) ? 1 : false ;
$gd = ( extension_loaded('gd2') ) ? 2 : $gd ;
$captcha_stat = $gd;
if ( $gd ){
mt_srand((double)microtime()*10000);
$random_num = mt_rand(0, 100000);
$security = ""._MD_SECURITY_CODE."  "
.""._MD_NO_SPAM."";
$captchatray = new XoopsFormElementTray('',' ','cappie');
$captchatray->addElement(new XoopsFormLabel('' , $security));
$captchatray->addElement(new XoopsFormHidden('sec_hidden',$random_num));
$captchatray->addElement(new XoopsFormText('','security',15,10,''));
$regtray->addElement($captchatray);
}
} else {
$captcha_stat = 99;
}

$ctobform->addElement(new XoopsFormHidden('captcha_stat', $captcha_stat));
// zyspec - end of security graphic code */
$sbtn=new XoopsFormButton('', '', _MD_SUBMIT, 'submit');
$regtray->addElement($sbtn);
$ctobform->addElement($regtray);
$ctobform->addElement(new XoopsFormHidden('tomailto',$email));
$ctobform->addElement(new XoopsFormHidden('lid',$lid));
$ctobform->addElement(new XoopsFormHidden('linktitle',$linktitle));
// $ctobform->addElement(new XoopsFormHidden('title',$title));
$ctobform->addElement(new XoopsFormHidden('subject',$linktitle.' '._MD_INQ.' '.$xoopsConfig['sitename']));
$ctobform->addElement(new XoopsFormHidden('thistemplate', 'ctob_mail.tpl'));
$ctobform->display();
}



//Tell A Friend
function tell(){
// global $xoopsModuleConfig, $_GET, $_REQUEST, $xoopsDB, $myts, $meta, $xoopsUser, $xoopsConfig;
global $xoopsConfig, $_GET, $xoopsDB, $myts, $meta, $xoopsUser;
global $xoopsModuleConfig, $_REQUEST, $xoopsDB, $myts, $meta, $xoopsUser;

$id = ( isset($_REQUEST['id']) )? $_REQUEST['id'] : null ;
$lid = ( isset($_REQUEST['lid']) )? $_REQUEST['lid'] : null ;
$op = ( isset($_REQUEST['op']) )? $_REQUEST['op'] : null ;
$sender = ( isset($_REQUEST['sender']) )? $_REQUEST['sender'] : null ;
$subject = ( isset($_REQUEST['subject']) )? $_REQUEST['subject'] : null ;
$body = ( isset($_REQUEST['body']) )? $_REQUEST['body'] : null ;
$xsname = ( isset($_REQUEST['sname']) )? $_REQUEST['sname'] : null ;
$xsemail = ( isset($_REQUEST['semail']) )? $_REQUEST['semail'] : null ;
$frname = ( isset($_REQUEST['frname']) )? $_REQUEST['frname'] : null ;
$fremail = ( isset($_REQUEST['fremail']) )? $_REQUEST['fremail'] : null ;

$result = $xoopsDB->query("SELECT title, email FROM ".$xoopsDB->prefix("xdir_links")." WHERE lid = '$lid'");
list($linktitle, $email) = $xoopsDB->fetchRow($result);

//may need 2.2 changes here due to u.n. conventions
if($xoopsUser) {
reset($xoopsUser);
$xsname =$xoopsUser->getVar("uname");
$xsname = ($xsname == "") ? $xoopsUser->getVar("name") : $xsname ;
$xsemail =$xoopsUser->getVar("email");
}
//print_r ($xoopsConfig);
//echo $xoopsUser->getVar("uname");
//echo $xoopsUser->getVar("email");
//echo "<=HERE";
//exit;
$tfform = new XoopsThemeForm(_MD_TELLAFRIEND, 'tfform', $_SERVER['PHP_SELF'].'?op=sendit', 'POST');
$tfform->addElement(new XoopsFormText(_MD_YOUR.' '._MD_NAME , 'sname', 50, 100,$xsname));
$tfform->addElement(new XoopsFormText(_MD_FRIEND.' '._MD_NAME , 'frname', 50, 50, ''));
$tfform->addElement(new XoopsFormText(_MD_FRIEND.' '._MD_EMAILC , 'fremail', 50, 50, ''));
$tfform->addElement(new XoopsFormLabel(_MD_SUBJECT, $subject));
$tfform->addElement(new XoopsFormLabel(_MD_TITLE, $linktitle));
$regtray = new XoopsFormElementTray('','','');

if ( empty($xoopsUser) && $xoopsModuleConfig['captcha_anon'] ) {
$gd = ( extension_loaded('gd') ) ? 1 : false ;
$gd = ( extension_loaded('gd2') ) ? 2 : $gd ;
$captcha_stat = $gd;
if ( $gd ){
mt_srand((double)microtime()*10000);
$random_num = mt_rand(0, 100000);
$security = ""._MD_SECURITY_CODE."  "
.""._MD_NO_SPAM."";
$captchatray = new XoopsFormElementTray('',' ','cappie');
$captchatray->addElement(new XoopsFormLabel('' , $security));
$captchatray->addElement(new XoopsFormHidden('sec_hidden',$random_num));
$captchatray->addElement(new XoopsFormText('','security',15,10,''));
$regtray->addElement($captchatray);
}
} else {
$captcha_stat = 99;
}

$tfform->addElement(new XoopsFormHidden('captcha_stat', $captcha_stat));
// zyspec - end of security graphic code */
$sbtn=new XoopsFormButton('', '', _MD_SUBMIT, 'submit');
$regtray->addElement($sbtn);
$tfform->addElement($regtray);
$tfform->addElement(new XoopsFormHidden('id',$id));
$tfform->addElement(new XoopsFormHidden('lid',$lid));
$tfform->addElement(new XoopsFormHidden('subject',$subject));
// $tfform->addElement(new XoopsFormHidden('body',$body));
$tfform->addElement(new XoopsFormHidden('linktitle',$linktitle));
$tfform->addElement(new XoopsFormHidden('thistemplate', 'tellafriend_mail.tpl'));
$tfform->display();
}

function sendit(){
global $xoopsConfig, $_POST, $xoopsDB, $myts, $meta, $mydirname;
include XOOPS_ROOT_PATH."/class/xoopsmailer.php";
// print_r ($_POST);
// exit;

extract($_POST, EXTR_PREFIX_ALL, "post");

$id = ( isset($post_id) )? ( $myts->htmlSpecialChars($post_id) ) : null ;
$lid = ( isset($post_lid) )? ( $myts->htmlSpecialChars($post_lid) ) : null ;
$op = ( isset($post_op) )? ( $myts->htmlSpecialChars($post_op) ) : null ;
$sender = ( isset($post_sender) )? ( $myts->htmlSpecialChars($post_sender) ) : null ;
$subject = ( isset($post_subject) )? ( $myts->htmlSpecialChars($post_subject) ) : null ;
$body = ( isset($post_body) )? ( $myts->htmlSpecialChars($post_body) ) : null ;
$sname = ( isset($post_sname) )? ( $myts->htmlSpecialChars($post_sname) ) : null ;
$semail = ( isset($post_semail) )? ( $myts->htmlSpecialChars($post_semail) ) : null ;
$frname = ( isset($post_frname) )? ( $myts->htmlSpecialChars($post_frname) ) : null ;
$tomailto = ( isset($post_fremail) )? ( $myts->htmlSpecialChars($post_fremail) ) : null ;
$title = ( isset($post_title) )? ( $myts->htmlSpecialChars($post_title) ) : null ;
$linktitle = ( isset($post_linktitle) )? ( $myts->htmlSpecialChars($post_linktitle) ) : null ;
$tomailto = ( isset($post_tomailto) )? ( $myts->htmlSpecialChars($post_tomailto) ) : $tomailto ;
$thistemplate = ( isset($post_thistemplate) )? $post_thistemplate : null ;

$xadminmail = $xoopsConfig['adminmail'];//setting from to server in case of SPF=>will admin config this as well
$xsitename = $xoopsConfig['sitename'];//Adding site title as sender (mod config this?)
$xsiteurl = $xoopsConfig['xoops_url'];//Adding site url
$linkurl = ( isset($lid) )? (XOOPS_URL.'/modules/'.$mydirname.'/singlelink.php?lid='.$lid) : null ;

// check captcha security
if ( empty($_POST['captcha_stat']) ) {
redirect_header("./",5,_MD_FAIL_SECURITY);
}
switch ($_POST['captcha_stat']) {
case false:
case 0:
redirect_header(XOOPS_URL."./",5,_MD_FAIL_GD_LOAD);
break;
case 1:
case 2:
if (empty($_POST["security"]) || empty($_POST["sec_hidden"])) {
$eh->show("0008");
} else {
// values are set - now verify
$sec_post = $myts->addSlashes($_POST["security"]);
$sec_post_hidden = $myts->addSlashes($_POST["sec_hidden"]);
$spass = mx_security_check($sec_post,$sec_post_hidden);
if ($spass === false){
redirect_header("./",5,_MD_FAIL_SECURITY);
}
}
break;
default:
break;
}
// end of security graphic validation check

//mail to customer and admin
$xoopsMailer =& getMailer(); //Get mailer object
$xoopsMailer->useMail(); // Set it to use email (as opposed to PM)
$xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$xoopsConfig['language'].'/mail_template/');
$xoopsMailer->setTemplate($thistemplate);

$xoopsMailer->assign('SNAME', $sname); //assign some vars for mail template
$xoopsMailer->assign('SEMAIL', $semail);
$xoopsMailer->assign('SUBJECT', $subject);
$xoopsMailer->assign('FRNAME', $frname);
$xoopsMailer->assign('FREMAIL', $fremail);
$xoopsMailer->assign('X_ADMINMAIL', $xadminmail);
$xoopsMailer->assign('X_SITENAME', $xsitename);
$xoopsMailer->assign('X_SITEURL', $xsiteurl);
$xoopsMailer->assign('X_LINK', $linkurl);
$xoopsMailer->assign('X_LINK_TITLE', $linktitle);
$xoopsMailer->assign('BODY', $body);


$xoopsMailer->setToEmails($tomailto);
$xoopsMailer->setFromEmail($xadminmail);
$xoopsMailer->setFromName($xsitename);
// $xoopsMailer->setBody($body); //if not using a mail template use setBody instead
$xoopsMailer->setSubject($subject);

//echo $mydirname;
//print_r ($xoopsMailer);
// exit;
if ($xoopsMailer->send()) {
// echo $xoopsMailer->getErrors();
// echo "<= That's Why";
// exit;
//send was successful
redirect_header("index.php",1,_CLA_MESSEND);
}else{
// echo $xoopsMailer->getErrors();
// echo "<= That's Why";
// exit;
redirect_header("index.php",1,_MD_ELOGOUNK);
}
include (XOOPS_ROOT_PATH."/footer.php");
}


//op switcher
if(!isset($_REQUEST['op'])) {
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'tell';
} else {
$op = $_REQUEST['op'];
}



switch ($op) {
case "tell":
tell();
break;
case "ctob":
ctob();
break;
case "sendit":
sendit();
break;
default:
redirect_header("contact.php?op=tell",1,""._RETURNGLO."");
break;
}
include_once (XOOPS_ROOT_PATH."/footer.php");
?>

Login

Who's Online

292 user(s) are online (215 user(s) are browsing Support Forums)


Members: 0


Guests: 292


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits