本文整理汇总了PHP中JMailHelper::cleanLine方法的典型用法代码示例。如果您正苦于以下问题:PHP JMailHelper::cleanLine方法的具体用法?PHP JMailHelper::cleanLine怎么用?PHP JMailHelper::cleanLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMailHelper
的用法示例。
在下文中一共展示了JMailHelper::cleanLine方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCleanLine
/**
* Test for the JMailHelper::cleanLine method.
*
* @param string $input The input to clean
* @param string $expected The expected result
*
* @return void
*
* @since 12.1
*
* @dataProvider dataCleanLine
*/
public function testCleanLine($input, $expected)
{
$this->assertThat(
JMailHelper::cleanLine($input),
$this->equalTo($expected)
);
}
示例2: addReplyTo
/**
* Add Reply to e-mail address(es) to the e-mail
*
* @access public
* @param array $reply Either an array or multi-array of form
* <pre>
* array( [0] => E-Mail Address [1] => Name )
* </pre>
* @return void
* @since 1.5
*/
function addReplyTo($replyto)
{
// Take care of reply email addresses
if (is_array($replyto[0]))
{
foreach ($replyto as $to) {
$to0 = JMailHelper::cleanLine( $to[0] );
$to1 = JMailHelper::cleanLine( $to[1] );
parent::AddReplyTo($to0, $to1);
}
} else {
$replyto0 = JMailHelper::cleanLine( $replyto[0] );
$replyto1 = JMailHelper::cleanLine( $replyto[1] );
parent::AddReplyTo($replyto0, $replyto1);
}
}
示例3: add
/**
* Add recipients to the email.
*
* @param mixed $recipient Either a string or array of strings [email address(es)]
* @param mixed $name Either a string or array of strings [name(s)]
* @param string $method The parent method's name.
*
* @return JMail Returns this object for chaining.
*
* @since 11.1
* @throws InvalidArgumentException
*/
protected function add($recipient, $name = '', $method = 'addAddress')
{
$method = lcfirst($method);
// If the recipient is an array, add each recipient... otherwise just add the one
if (is_array($recipient)) {
if (is_array($name)) {
$combined = array_combine($recipient, $name);
if ($combined === false) {
throw new InvalidArgumentException("The number of elements for each array isn't equal.");
}
foreach ($combined as $recipientEmail => $recipientName) {
$recipientEmail = JMailHelper::cleanLine($recipientEmail);
$recipientName = JMailHelper::cleanLine($recipientName);
call_user_func('parent::' . $method, $recipientEmail, $recipientName);
}
} else {
$name = JMailHelper::cleanLine($name);
foreach ($recipient as $to) {
$to = JMailHelper::cleanLine($to);
call_user_func('parent::' . $method, $to, $name);
}
}
} else {
$recipient = JMailHelper::cleanLine($recipient);
call_user_func('parent::' . $method, $recipient, $name);
}
return $this;
}
示例4: createMailer
/**
* Create a mailer object
*
* @return JMail object
*
* @see JMail
* @since 11.1
*/
protected static function createMailer()
{
$conf = self::getConfig();
$smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
$smtpuser = $conf->get('smtpuser');
$smtppass = $conf->get('smtppass');
$smtphost = $conf->get('smtphost');
$smtpsecure = $conf->get('smtpsecure');
$smtpport = $conf->get('smtpport');
$mailfrom = $conf->get('mailfrom');
$fromname = $conf->get('fromname');
$mailer = $conf->get('mailer');
// Create a JMail object
$mail = JMail::getInstance();
// Set default sender without Reply-to
$mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
// Default mailer is to use PHP's mail function
switch ($mailer) {
case 'smtp':
$mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
break;
case 'sendmail':
$mail->IsSendmail();
break;
default:
$mail->IsMail();
break;
}
return $mail;
}
示例5: doemail
function doemail()
{
jimport('joomla.mail.helper');
jimport('joomla.filesystem.file');
jimport('joomla.client.helper');
global $mainframe;
JClientHelper::setCredentialsFromRequest('ftp');
$config =& JFactory::getConfig();
$folder = '';
$filepaths = array();
$attached = 0;
$notattached = 0;
foreach (JRequest::get('FILES') as $elname => $file) {
if ($file['name'] != '') {
if ($folder == '') {
$folder = $config->getValue('config.tmp_path') . DS . uniqid('com_fabrik.plg.table.emailtableplus.');
if (!JFolder::create($folder)) {
JError::raiseWarning(E_NOTICE, JText::_('Could not upload files'));
break;
}
}
$filepath = $folder . DS . JFile::makeSafe($file['name']);
if (JFile::upload($file['tmp_name'], $filepath)) {
$filepaths[count($filepaths)] = $filepath;
$attached++;
} else {
JError::raiseWarning(E_NOTICE, JText::sprintf('Could not upload file %s', $file['name']));
}
}
}
$renderOrder = JRequest::getInt('renderOrder', 0);
$subject = JMailHelper::cleanSubject(JRequest::getVar('subject'));
$message = JMailHelper::cleanBody(JRequest::getVar('message'));
$recordids = explode(',', JRequest::getVar('recordids'));
$tableModel =& $this->getModel('Table');
$tableModel->setId(JRequest::getVar('id', 0));
$formModel =& $tableModel->getForm();
$this->formModel =& $formModel;
$params =& $tableModel->getParams();
$elementModel =& JModel::getInstance('element', 'FabrikModel');
$field_name = $params->get('emailtableplus_field_name');
if (is_array($field_name)) {
$field_name = $field_name[$renderOrder];
}
$elementModel->setId($field_name);
$element =& $elementModel->getElement(true);
$tonamefield = $elementModel->getFullName(false, true, false);
$field_email = $params->get('emailtableplus_field_email');
if (is_array($field_email)) {
$field_email = $field_email[$renderOrder];
}
$elementModel->setId($field_email);
$element =& $elementModel->getElement(true);
$tofield = $elementModel->getFullName(false, true, false);
$fromUser = $params->get('emailtableplus_from_user');
if (is_array($fromUser)) {
$fromUser = $fromUser[$renderOrder];
}
if ($fromUser[0]) {
$my =& JFactory::getUser();
$from = $my->get('email');
$fromname = $my->get('name');
} else {
$config =& JFactory::getConfig();
$from = $config->getValue('mailfrom');
$fromname = $config->getValue('fromname');
}
$ubcc = $params->get('emailtableplus_use_BCC');
if (is_array($ubcc)) {
$ubcc = $ubcc[$renderOrder];
}
$useBCC = $ubcc && count($recordids) > 0 && !preg_match('/{[^}]*}/', $subject) && !preg_match('/{[^}]*}/', $message);
/*
$include_rowdata = $params->get('emailtableplus_include_rowdata');
if (is_array($include_rowdata)) {
$include_rowdata = $include_rowdata[$renderOrder];
}
*/
$sent = 0;
$notsent = 0;
if ($useBCC) {
$bcc = array();
foreach ($recordids as $id) {
$row = $tableModel->getRow($id);
//$message .= $this->_getTextEmail( JArrayHelper::fromObject($row));
$to = $row->{$tofield};
$toname = $row->{$tonamefield};
if (JMailHelper::cleanAddress($to) && JMailHelper::isEmailAddress($to)) {
$tofull = '"' . JMailHelper::cleanLine($toname) . '" <' . $to . '>';
$bcc[$sent] = $tofull;
$sent++;
} else {
$notsent++;
}
}
// $$$ hugh - working round bug in the SMTP mailer method:
// http://forum.joomla.org/viewtopic.php?f=199&t=530189&p=2190233#p2190233
// ... which basically means if using the SMTP method, we MUST specify a To addrees,
// so if mailer is smtp, we'll set the To address to the same as From address
if ($config->getValue('mailer') == 'smtp') {
//.........这里部分代码省略.........
示例6: 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;
}
示例7: add
/**
* Add recipients to the email.
*
* @param mixed $recipient Either a string or array of strings [email address(es)]
* @param mixed $name Either a string or array of strings [name(s)]
* @param string $method The parent method's name.
*
* @return JMail|boolean Returns this object for chaining on success or boolean false on failure.
*
* @since 11.1
* @throws InvalidArgumentException
*/
protected function add($recipient, $name = '', $method = 'addAddress')
{
$method = lcfirst($method);
// If the recipient is an array, add each recipient... otherwise just add the one
if (is_array($recipient)) {
if (is_array($name)) {
$combined = array_combine($recipient, $name);
if ($combined === false) {
throw new InvalidArgumentException("The number of elements for each array isn't equal.");
}
foreach ($combined as $recipientEmail => $recipientName) {
$recipientEmail = JMailHelper::cleanLine($recipientEmail);
$recipientName = JMailHelper::cleanLine($recipientName);
// Wrapped in try/catch if PHPMailer is configured to throw exceptions
try {
// Check for boolean false return if exception handling is disabled
if (call_user_func('parent::' . $method, $recipientEmail, $recipientName) === false) {
return false;
}
} catch (phpmailerException $e) {
// The parent method will have already called the logging callback, just log our deprecated error handling message
JLog::add(__METHOD__ . '() will not catch phpmailerException objects as of 4.0.', JLog::WARNING, 'deprecated');
return false;
}
}
} else {
$name = JMailHelper::cleanLine($name);
foreach ($recipient as $to) {
$to = JMailHelper::cleanLine($to);
// Wrapped in try/catch if PHPMailer is configured to throw exceptions
try {
// Check for boolean false return if exception handling is disabled
if (call_user_func('parent::' . $method, $to, $name) === false) {
return false;
}
} catch (phpmailerException $e) {
// The parent method will have already called the logging callback, just log our deprecated error handling message
JLog::add(__METHOD__ . '() will not catch phpmailerException objects as of 4.0.', JLog::WARNING, 'deprecated');
return false;
}
}
}
} else {
$recipient = JMailHelper::cleanLine($recipient);
// Wrapped in try/catch if PHPMailer is configured to throw exceptions
try {
// Check for boolean false return if exception handling is disabled
if (call_user_func('parent::' . $method, $recipient, $name) === false) {
return false;
}
} catch (phpmailerException $e) {
// The parent method will have already called the logging callback, just log our deprecated error handling message
JLog::add(__METHOD__ . '() will not catch phpmailerException objects as of 4.0.', JLog::WARNING, 'deprecated');
return false;
}
}
return $this;
}
示例8: getMailer
function getMailer()
{
if (!FSS_Settings::Get('email_send_override')) {
$mailer = JFactory::getMailer();
$mailer->setSender($this->Get_Sender());
$mailer->CharSet = 'UTF-8';
return $mailer;
}
$smtpauth = FSS_Settings::Get('email_send_smtp_auth') == 0 ? null : 1;
$smtpuser = FSS_Settings::Get('email_send_smtp_username');
// $conf->get('smtpuser');
$smtppass = FSS_Settings::Get('email_send_smtp_password');
// $conf->get('smtppass');
$smtphost = FSS_Settings::Get('email_send_smtp_host');
// $conf->get('smtphost');
$smtpsecure = FSS_Settings::Get('email_send_smtp_security');
// $conf->get('smtpsecure');
$smtpport = FSS_Settings::Get('email_send_smtp_port');
// $conf->get('smtpport');
$mailfrom = FSS_Settings::Get('email_send_from_email');
// $conf->get('mailfrom');
$fromname = FSS_Settings::Get('email_send_from_name');
// $conf->get('fromname');
$mailer = FSS_Settings::Get('email_send_mailer');
// $conf->get('mailer');
// Create a JMail object
$mail = new JMail();
// Set default sender without Reply-to
$mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
// Default mailer is to use PHP's mail function
switch ($mailer) {
case 'smtp':
$mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
break;
case 'sendmail':
$mail->IsSendmail();
break;
default:
$mail->IsMail();
break;
}
$mail->CharSet = 'UTF-8';
return $mail;
}
示例9: cleanLine
/**
* Helper wrapper method for cleanLine
*
* @param string $value String to be cleaned.
*
* @return string Cleaned string.
*
* @see JMailHelper::cleanLine()
* @since 3.4
*/
public function cleanLine($value)
{
return JMailHelper::cleanLine($value);
}
示例10: createMailer
/**
* Create a mailer object
*
* @return JMail object
*
* @see JMail
* @since 11.1
*/
protected static function createMailer()
{
$conf = self::getConfig();
$smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
$smtpuser = $conf->get('smtpuser');
$smtppass = $conf->get('smtppass');
$smtphost = $conf->get('smtphost');
$smtpsecure = $conf->get('smtpsecure');
$smtpport = $conf->get('smtpport');
$mailfrom = $conf->get('mailfrom');
$fromname = $conf->get('fromname');
$mailer = $conf->get('mailer');
// Create a JMail object
$mail = JMail::getInstance();
// Clean the email address
$mailfrom = JMailHelper::cleanLine($mailfrom);
// Set default sender without Reply-to if the mailfrom is a valid address
if (JMailHelper::isEmailAddress($mailfrom)) {
// Wrap in try/catch to catch phpmailerExceptions if it is throwing them
try {
// Check for a false return value if exception throwing is disabled
if ($mail->setFrom($mailfrom, JMailHelper::cleanLine($fromname), false) === false) {
JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail');
}
} catch (phpmailerException $e) {
JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail');
}
}
// Default mailer is to use PHP's mail function
switch ($mailer) {
case 'smtp':
$mail->useSmtp($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
break;
case 'sendmail':
$mail->isSendmail();
break;
default:
$mail->isMail();
break;
}
return $mail;
}
示例11: addReplyTo
/**
* Add Reply to e-mail address(es) to the e-mail
*
* @access public
* @param array $reply Either an array or multi-array of form
* <pre>
* array( [0] => E-Mail Address [1] => Name )
* </pre>
* @return void
* @since 1.5
*/
public function addReplyTo($replyto) {
// Take care of reply email addresses
if (is_array($replyto[0])) {
foreach ($replyto as $to) {
$to0 = JMailHelper::cleanLine($to[0]);
$to1 = JMailHelper::cleanLine($to[1]);
parent::AddReplyTo($to0, $to1);
}
} else {
$replyto0 = JMailHelper::cleanLine($replyto[0]);
$replyto1 = JMailHelper::cleanLine($replyto[1]);
parent::AddReplyTo($replyto0, $replyto1);
}
if (FMSTS_JVERSION == '16') {
return $this;
}
}
示例12: createMailer
protected static function createMailer()
{
$input = JFactory::getApplication()->input;
$smtpauth = $input->get('smtp_auth', 0);
$smtpuser = $input->get('smtp_user', false, 'string');
$smtppass = $input->get('smtp_pass', false, 'string');
$smtphost = $input->get('smtp_host', false);
$smtpsecure = $input->get('smtp_secure', false);
$smtpport = $input->get('smtp_port', false);
$mailfrom = $input->get('from_email', false, 'string');
$fromname = $input->get('from_name', false);
$mailer = $input->get('mailer', false);
// Create a JMail object
$mail = JMail::getInstance();
// Set default sender without Reply-to
$mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
// Default mailer is to use PHP's mail function
switch ($mailer)
{
case 'smtp':
$mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
break;
case 'sendmail':
$mail->IsSendmail();
break;
default:
$mail->IsMail();
break;
}
return $mail;
}