php - add html ouput in joomla email -
i trying set html on output of email send joomla. file located in joomla core. know have add ->ishtml(true); not know , how. here code:
class mailtocontroller extends jcontrollerlegacy { /** * show form user can send link someone. * * @return void * * @since 1.5 */ public function mailto() { $session = jfactory::getsession(); $session->set('com_mailto.formtime', time()); $this->input->set('view', 'mailto'); $this->display(); } public function send() { // check request forgeries jsession::checktoken() or jexit(jtext::_('jinvalid_token')); $app = jfactory::getapplication(); $session = jfactory::getsession(); $timeout = $session->get('com_mailto.formtime', 0); if ($timeout == 0 || time() - $timeout < 1) { jerror::raisenotice(500, jtext::_('com_mailto_email_not_sent')); return $this->mailto(); } $sitename = $app->get('sitename'); $link = mailtohelper::validatehash($this->input->get('link', '', 'post')); // verify local link if (!$link || !juri::isinternal($link)) { // non-local url... jerror::raisenotice(500, jtext::_('com_mailto_email_not_sent')); return $this->mailto(); } // array of email headers not want allow input $headers = array ( 'content-type:', 'mime-version:', 'content-transfer-encoding:', 'bcc:', 'cc:' ); // array of input fields scan injected headers $fields = array( 'mailto', 'sender', 'from', 'subject', ); /* * here meat , potatoes of header injection test. * iterate on array of form input , check header strings. * if find one, send unauthorized header , die. */ foreach ($fields $field) { foreach ($headers $header) { if (strpos($_post[$field], $header) !== false) { jerror::raiseerror(403, ''); } } } /* * free memory */ unset ($headers, $fields); $email = $this->input->post->getstring('mailto', ''); $sender = $this->input->post->getstring('sender', ''); $from = $this->input->post->getstring('from', ''); $subject_default = jtext::sprintf('com_mailto_sent_by', $sender); $subject = $this->input->post->getstring('subject', $subject_default); // check valid address $error = false; if (!$email || !jmailhelper::isemailaddress($email)) { $error = jtext::sprintf('com_mailto_email_invalid', $email); jerror::raisewarning(0, $error); } // check valid address if (!$from || !jmailhelper::isemailaddress($from)) { $error = jtext::sprintf('com_mailto_email_invalid', $from); jerror::raisewarning(0, $error); } if ($error) { return $this->mailto(); } // build message send $msg = jtext::_('com_mailto_email_msg'); $link = $link; //$body = sprintf($msg, $sitename, $sender, $from, $link); $body = "<p>hello test f,</p><br/><p>thank registering @ deals&offers. account created , activated.</p><br/>you may login ".$sitename." using following username , password:</br><p>username: ".$sender."</p><p>password: ".$from."/p><br/><p><b>note:</b> recomended change password after first login. ".$link."</p>"; // clean email data $subject = jmailhelper::cleansubject($subject); $body = jmailhelper::cleanbody($body); // send need use punycode. $from = jstringpunycode::emailtopunycode($from); $from = jmailhelper::cleanaddress($from); $email = jstringpunycode::emailtopunycode($email); // send email if (jfactory::getmailer()->sendmail($from, $sender, $email, $subject, $body) !== true) { jerror::raisenotice(500, jtext::_('com_mailto_email_not_sent')); return $this->mailto(); } jfactory::getapplication()->enqueuemessage('ok!', ''); $this->input->set('view', 'sent'); $this->display(); } }
thank much
you can add before body or between subject , body . however, must before submit command !! here example of phpmailler firstly, need call class , can use it
$this->mail= new phpmailer(); $this->mail->issmtp(); $this->mailishtml(true); $subject = jmailhelper::cleansubject($subject); $body = jmailhelper::cleanbody($body);
however if function static call function in same class can call function sef command
self::mailishtml(true)
Comments
Post a Comment