本文整理汇总了PHP中JMailHelper::cleanText方法的典型用法代码示例。如果您正苦于以下问题:PHP JMailHelper::cleanText方法的具体用法?PHP JMailHelper::cleanText怎么用?PHP JMailHelper::cleanText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMailHelper
的用法示例。
在下文中一共展示了JMailHelper::cleanText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCleanText
/**
* @group framework.mail
* @dataProvider getCleanTextData
*/
public function testCleanText( $input, $expected )
{
$this->assertThat(
JMailHelper::cleanText( $input ),
$this->equalTo( $expected )
);
}
示例2: setBody
/**
* Set the E-Mail body
*
* @access public
* @param string $content Body of the e-mail
* @return void
* @since 1.5
*/
function setBody($content)
{
/*
* Filter the Body
* TODO: Check for XSS
*/
$this->Body = JMailHelper::cleanText( $content );
}
示例3: sendContactForm
public function sendContactForm()
{
jimport('joomla.mail.helper');
$app = JFactory::getApplication();
// Get a JMail instance
$mailer = JFactory::getMailer();
$params = $app->getParams();
$defaultFrom = $mailer->From;
$defaultFromname = $mailer->FromName;
$data = array('name' => JMailHelper::cleanLine($this->getState('contact.name')), 'email' => JMailHelper::cleanAddress($this->getState('contact.email')), 'telephone' => JMailHelper::cleanLine($this->getState('contact.telephone')), 'subject' => JMailHelper::cleanSubject($this->getState('contact.subject')) . ' [' . $defaultFromname . ']', 'message' => JMailHelper::cleanText($this->getState('contact.message')), 'propertyURL' => $this->getState('contact.propertyURL'));
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('jea');
if ($params->get('use_captcha')) {
$plugin = JFactory::getConfig()->get('captcha');
if ($plugin == '0') {
$plugin = 'recaptcha';
}
$captcha = JCaptcha::getInstance($plugin);
// Test the value.
if (!$captcha->checkAnswer('')) {
$error = $captcha->getError();
if ($error instanceof Exception) {
$this->setError($error->getMessage());
} else {
$this->setError($error);
}
}
}
// Check data
if (empty($data['name'])) {
$this->setError(JText::_('COM_JEA_YOU_MUST_TO_ENTER_YOUR_NAME'));
}
if (empty($data['message'])) {
$this->setError(JText::_('COM_JEA_YOU_MUST_TO_ENTER_A_MESSAGE'));
}
if (!JMailHelper::isEmailAddress($data['email'])) {
$this->setError(JText::sprintf('COM_JEA_INVALID_EMAIL_ADDRESS', $data['email']));
}
if ($this->getErrors()) {
return false;
}
$result = $dispatcher->trigger('onBeforeSendContactForm', array($data));
if (in_array(false, $result, true)) {
return false;
}
$recipients = array();
$defaultMail = $params->get('default_mail');
$agentMail = '';
if ($params->get('send_form_to_agent') == 1) {
$item = $this->getItem();
$db = $this->getDbo();
$q = 'SELECT `email` FROM `#__users` WHERE `id`=' . (int) $item->created_by;
$db->setQuery($q);
$agentMail = $db->loadResult();
}
if (!empty($defaultMail) && !empty($agentMail)) {
$recipients[] = $defaultMail;
$recipients[] = $agentMail;
} elseif (!empty($defaultMail)) {
$recipients[] = $defaultMail;
} elseif (!empty($agentMail)) {
$recipients[] = $agentMail;
} else {
// Send to the webmaster email
$recipients[] = $defaultFrom;
}
$body = $data['message'] . "\n";
if (!empty($data['telephone'])) {
$body .= "\n" . JText::_('COM_JEA_TELEPHONE') . ' : ' . $data['telephone'];
}
$body .= "\n" . JText::_('COM_JEA_PROPERTY_URL') . ' : ' . $data['propertyURL'];
$mailer->setBody($body);
$ret = $mailer->sendMail($data['email'], $data['name'], $recipients, $data['subject'], $body, false);
if ($ret == true) {
$app->setUserState('contact.name', '');
$app->setUserState('contact.email', '');
$app->setUserState('contact.telephone', '');
$app->setUserState('contact.subject', '');
$app->setUserState('contact.message', '');
return true;
}
return false;
}
示例4: sendMail
/**
* Function to send an email
*
* @param string $from From email address
* @param string $fromName From name
* @param mixed $recipient Recipient email address(es)
* @param string $subject email subject
* @param string $body Message body
* @param boolean $mode false = plain text, true = HTML
* @param mixed $cc CC email address(es)
* @param mixed $bcc BCC email address(es)
* @param mixed $attachment Attachment file name(s)
* @param mixed $replyTo Reply to email address(es)
* @param mixed $replyToName Reply to name(s)
*
* @return boolean True on success
*
* @since 11.1
*/
public static function sendMail($from, $fromName, $recipient, $subject, $body, $mode = false, $cc = null, $bcc = null, $attachment = null, $replyTo = null, $replyToName = null)
{
// do a couple of tweaks to improve spam scores
// If html, make sure there's an <html> tag
if ($mode) {
if (!stristr($body, '<html>')) {
$body = '<html>' . $body . '</html>';
}
}
// if simple single email recipient with no name part, fake out name part to avoid TO_NO_BKRT hit in spam filters
$recipientName = '';
if (is_string($recipient) && !strstr($recipient, '<')) {
$recipientName = $recipient;
}
// Get a JMail instance
$mailer = JFactory::getMailer();
$mailer->setSubject($subject);
$mailer->setBody($body);
$mailer->Encoding = 'base64';
// Are we sending the email as HTML?
$mailer->isHtml($mode);
try {
$mailer->addRecipient($recipient, $recipientName);
} catch (Exception $e) {
return false;
}
try {
$mailer->addCc($cc);
} catch (Exception $e) {
// not sure if we should bail if Cc is bad, for now just soldier on
}
try {
$mailer->addBcc($bcc);
} catch (Exception $e) {
// not sure if we should bail if Bcc is bad, for now just soldier on
}
try {
$mailer->addAttachment($attachment);
} catch (Exception $e) {
// most likely file didn't exist, ignore
}
$autoReplyTo = false;
// Take care of reply email addresses
if (is_array($replyTo)) {
$numReplyTo = count($replyTo);
for ($i = 0; $i < $numReplyTo; $i++) {
try {
$mailer->addReplyTo($replyTo[$i], $replyToName[$i]);
} catch (Exception $e) {
// carry on
}
}
} elseif (isset($replyTo)) {
try {
$mailer->addReplyTo($replyTo, $replyToName);
} catch (Exception $e) {
// carry on
}
} else {
$autoReplyTo = true;
}
try {
$mailer->setSender(array($from, $fromName, $autoReplyTo));
} catch (Exception $e) {
return false;
}
/**
* Set the plain text AltBody, which forces the PHP mailer class to make this
* a multipart MIME type, with an alt body for plain text. If we don't do this,
* the default behavior is to send it as just text/html, which causes spam filters
* to downgrade it.
*/
if ($mode) {
$mailer->AltBody = JMailHelper::cleanText(strip_tags($body));
}
try {
$ret = $mailer->Send();
} catch (Exception $e) {
return false;
}
return $ret;
//.........这里部分代码省略.........
示例5: cleanText
/**
* Helper wrapper method for cleanText
*
* @param string $value Multi-line string to be cleaned.
*
* @return string Cleaned multi-line string.
*
* @see JMailHelper::cleanText()
* @since 3.4
*/
public function cleanText($value)
{
return JMailHelper::cleanText($value);
}
示例6: send
/**
* The main method for letter sending.
*
* @param array $params - the configuration of letter
*
* @return boolean
* @since 1.0
*/
public function send($params = null)
{
if ($params) {
$this->_setData($params);
}
$this->ClearAddresses();
$this->AddReplyTo(JMailHelper::cleanAddress($this->toEmail), JMailHelper::cleanText($this->toName));
$this->SetFrom(JMailHelper::cleanAddress($this->fromEmail), JMailHelper::cleanText($this->fromName));
$this->Subject = JMailHelper::cleanText($this->letter->subject);
if (!empty($this->letter->encoding)) {
$this->CharSet = $this->letter->encoding;
}
$this->Body = JMailHelper::cleanText($this->letter->content);
foreach ($this->attach as $item) {
$parts = explode(DS, $item->filename);
$full = JPATH_ROOT . DS . $item->filename;
if (function_exists('mime_content_type')) {
$mime = mime_content_type($full);
} elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mime = finfo_file($finfo, $full);
finfo_close($finfo);
list($mime) = explode(';', $mime);
} else {
$mime = 'application/octet-stream';
}
parent::AddAttachment($full, '', 'base64', $mime);
}
parent::IsHTML($params['type'] == 'html');
foreach ($this->emails as $email) {
if (!empty($email->email)) {
parent::addAddress($email->email, !empty($email->name) ? $email->name : "");
}
}
try {
if (!parent::Send()) {
throw new Exception();
}
} catch (Exception $e) {
$msg = $e->getMessage();
if (!empty($msg)) {
$this->setError($msg);
}
LogHelper::addDebug('Mailer.Sender error.', LogHelper::CAT_MAILER, $this->getErrors());
return false;
}
return true;
}
示例7: setBody
/**
* Set the E-Mail body
*
* @access public
* @param string $content Body of the e-mail
* @return void
* @since 1.5
*/
public function setBody($content) {
/*
* Filter the Body
* TODO: Check for XSS
*/
$this->Body = JMailHelper::cleanText($content);
if (FMSTS_JVERSION == '16') {
return $this;
}
}