本文整理汇总了PHP中String::splitFriendlyEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP String::splitFriendlyEmail方法的具体用法?PHP String::splitFriendlyEmail怎么用?PHP String::splitFriendlyEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::splitFriendlyEmail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the controller
*/
public function run()
{
global $objPage;
$pageId = $this->getPageIdFromUrl();
$objRootPage = null;
// Load a website root page object if there is no page ID
if ($pageId === null) {
$objRootPage = $this->getRootPageFromUrl();
$objHandler = new $GLOBALS['TL_PTY']['root']();
$pageId = $objHandler->generate($objRootPage->id, true);
} elseif ($pageId === false) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
} elseif (Config::get('rewriteURL') && strncmp(Environment::get('request'), 'index.php/', 10) === 0) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
}
// Get the current page object(s)
$objPage = PageModel::findPublishedByIdOrAlias($pageId);
// Check the URL and language of each page if there are multiple results
if ($objPage !== null && $objPage->count() > 1) {
$objNewPage = null;
$arrPages = array();
// Order by domain and language
while ($objPage->next()) {
$objCurrentPage = $objPage->current()->loadDetails();
$domain = $objCurrentPage->domain ?: '*';
$arrPages[$domain][$objCurrentPage->rootLanguage] = $objCurrentPage;
// Also store the fallback language
if ($objCurrentPage->rootIsFallback) {
$arrPages[$domain]['*'] = $objCurrentPage;
}
}
$strHost = Environment::get('host');
// Look for a root page whose domain name matches the host name
if (isset($arrPages[$strHost])) {
$arrLangs = $arrPages[$strHost];
} else {
$arrLangs = $arrPages['*'] ?: array();
// empty domain
}
// Use the first result (see #4872)
if (!Config::get('addLanguageToUrl')) {
$objNewPage = current($arrLangs);
} elseif (($lang = Input::get('language')) != '' && isset($arrLangs[$lang])) {
$objNewPage = $arrLangs[$lang];
}
// Store the page object
if (is_object($objNewPage)) {
$objPage = $objNewPage;
}
}
// Throw a 404 error if the page could not be found or the result is still ambiguous
if ($objPage === null || $objPage instanceof Model\Collection && $objPage->count() != 1) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
}
// Make sure $objPage is a Model
if ($objPage instanceof Model\Collection) {
$objPage = $objPage->current();
}
// Load a website root page object (will redirect to the first active regular page)
if ($objPage->type == 'root') {
$objHandler = new $GLOBALS['TL_PTY']['root']();
$objHandler->generate($objPage->id);
}
// Inherit the settings from the parent pages if it has not been done yet
if (!is_bool($objPage->protected)) {
$objPage->loadDetails();
}
// Set the admin e-mail address
if ($objPage->adminEmail != '') {
list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = String::splitFriendlyEmail($objPage->adminEmail);
} else {
list($GLOBALS['TL_ADMIN_NAME'], $GLOBALS['TL_ADMIN_EMAIL']) = String::splitFriendlyEmail(Config::get('adminEmail'));
}
// Exit if the root page has not been published (see #2425)
// Do not try to load the 404 page, it can cause an infinite loop!
if (!BE_USER_LOGGED_IN && !$objPage->rootIsPublic) {
header('HTTP/1.1 404 Not Found');
die_nicely('be_no_page', 'Page not found');
}
// Check wether the language matches the root page language
if (Config::get('addLanguageToUrl') && Input::get('language') != $objPage->rootLanguage) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($pageId);
}
// Check whether there are domain name restrictions
if ($objPage->domain != '') {
// Load an error 404 page object
if ($objPage->domain != Environment::get('host')) {
$this->User->authenticate();
$objHandler = new $GLOBALS['TL_PTY']['error_404']();
//.........这里部分代码省略.........
示例2: validator
//.........这里部分代码省略.........
} else {
// Validate the date (see #5086)
try {
new \Date($varInput, \Date::getNumericDateFormat());
} catch (\OutOfBoundsException $e) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
}
}
break;
// Check whether the current value is a valid time format
// Check whether the current value is a valid time format
case 'time':
if (!\Validator::isTime($varInput)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['time'], \Date::getInputFormat(\Date::getNumericTimeFormat())));
}
break;
// Check whether the current value is a valid date and time format
// Check whether the current value is a valid date and time format
case 'datim':
if (!\Validator::isDatim($varInput)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['dateTime'], \Date::getInputFormat(\Date::getNumericDatimFormat())));
} else {
// Validate the date (see #5086)
try {
new \Date($varInput, \Date::getNumericDatimFormat());
} catch (\OutOfBoundsException $e) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
}
}
break;
// Check whether the current value is a valid friendly name e-mail address
// Check whether the current value is a valid friendly name e-mail address
case 'friendly':
list($strName, $varInput) = \String::splitFriendlyEmail($varInput);
// no break;
// Check whether the current value is a valid e-mail address
// no break;
// Check whether the current value is a valid e-mail address
case 'email':
if (!\Validator::isEmail($varInput)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['email'], $this->strLabel));
}
if ($this->rgxp == 'friendly' && $strName != '') {
$varInput = $strName . ' [' . $varInput . ']';
}
break;
// Check whether the current value is list of valid e-mail addresses
// Check whether the current value is list of valid e-mail addresses
case 'emails':
$arrEmails = trimsplit(',', $varInput);
foreach ($arrEmails as $strEmail) {
$strEmail = \Idna::encodeEmail($strEmail);
if (!\Validator::isEmail($strEmail)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['emails'], $this->strLabel));
break;
}
}
break;
// Check whether the current value is a valid URL
// Check whether the current value is a valid URL
case 'url':
if (!\Validator::isUrl($varInput)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['url'], $this->strLabel));
}
break;
// Check whether the current value is a valid alias
示例3: compileRecipients
/**
* Extract the e-mail addresses from the func_get_args() arguments
*
* @param array $arrRecipients The recipients array
*
* @return array An array of e-mail addresses
*/
protected function compileRecipients($arrRecipients)
{
$arrReturn = array();
foreach ($arrRecipients as $varRecipients) {
if (!is_array($varRecipients)) {
$varRecipients = \String::splitCsv($varRecipients);
}
// Support friendly name addresses and internationalized domain names
foreach ($varRecipients as $v) {
list($strName, $strEmail) = \String::splitFriendlyEmail($v);
$strName = trim($strName, ' "');
$strEmail = \Idna::encodeEmail($strEmail);
if ($strName != '') {
$arrReturn[$strEmail] = $strName;
} else {
$arrReturn[] = $strEmail;
}
}
}
return $arrReturn;
}
示例4: send
/**
* Renturn a form to choose an existing style sheet and import it
*
* @param \DataContainer $dc
*
* @return string
*/
public function send(\DataContainer $dc)
{
$objNewsletter = $this->Database->prepare("SELECT n.*, c.useSMTP, c.smtpHost, c.smtpPort, c.smtpUser, c.smtpPass FROM tl_newsletter n LEFT JOIN tl_newsletter_channel c ON n.pid=c.id WHERE n.id=?")->limit(1)->execute($dc->id);
// Return if there is no newsletter
if ($objNewsletter->numRows < 1) {
return '';
}
// Overwrite the SMTP configuration
if ($objNewsletter->useSMTP) {
\Config::set('useSMTP', true);
\Config::set('smtpHost', $objNewsletter->smtpHost);
\Config::set('smtpUser', $objNewsletter->smtpUser);
\Config::set('smtpPass', $objNewsletter->smtpPass);
\Config::set('smtpEnc', $objNewsletter->smtpEnc);
\Config::set('smtpPort', $objNewsletter->smtpPort);
}
// Add default sender address
if ($objNewsletter->sender == '') {
list($objNewsletter->senderName, $objNewsletter->sender) = \String::splitFriendlyEmail(\Config::get('adminEmail'));
}
$arrAttachments = array();
$blnAttachmentsFormatError = false;
// Add attachments
if ($objNewsletter->addFile) {
$files = deserialize($objNewsletter->files);
if (!empty($files) && is_array($files)) {
$objFiles = \FilesModel::findMultipleByUuids($files);
if ($objFiles === null) {
if (!\Validator::isUuid($files[0])) {
$blnAttachmentsFormatError = true;
\Message::addError($GLOBALS['TL_LANG']['ERR']['version2format']);
}
} else {
while ($objFiles->next()) {
if (is_file(TL_ROOT . '/' . $objFiles->path)) {
$arrAttachments[] = $objFiles->path;
}
}
}
}
}
// Replace insert tags
$html = $this->replaceInsertTags($objNewsletter->content, false);
$text = $this->replaceInsertTags($objNewsletter->text, false);
// Convert relative URLs
if ($objNewsletter->externalImages) {
$html = $this->convertRelativeUrls($html);
}
// Send newsletter
if (!$blnAttachmentsFormatError && \Input::get('token') != '' && \Input::get('token') == $this->Session->get('tl_newsletter_send')) {
$referer = preg_replace('/&(amp;)?(start|mpc|token|recipient|preview)=[^&]*/', '', \Environment::get('request'));
// Preview
if (isset($_GET['preview'])) {
// Check the e-mail address
if (!\Validator::isEmail(\Input::get('recipient', true))) {
$_SESSION['TL_PREVIEW_MAIL_ERROR'] = true;
$this->redirect($referer);
}
$arrRecipient['email'] = urldecode(\Input::get('recipient', true));
// Send
$objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
$this->sendNewsletter($objEmail, $objNewsletter, $arrRecipient, $text, $html);
// Redirect
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter']['confirm'], 1));
$this->redirect($referer);
}
// Get the total number of recipients
$objTotal = $this->Database->prepare("SELECT COUNT(DISTINCT email) AS count FROM tl_newsletter_recipients WHERE pid=? AND active=1")->execute($objNewsletter->pid);
// Return if there are no recipients
if ($objTotal->count < 1) {
$this->Session->set('tl_newsletter_send', null);
\Message::addError($GLOBALS['TL_LANG']['tl_newsletter']['error']);
$this->redirect($referer);
}
$intTotal = $objTotal->count;
// Get page and timeout
$intTimeout = \Input::get('timeout') > 0 ? \Input::get('timeout') : 1;
$intStart = \Input::get('start') ? \Input::get('start') : 0;
$intPages = \Input::get('mpc') ? \Input::get('mpc') : 10;
// Get recipients
$objRecipients = $this->Database->prepare("SELECT *, r.email FROM tl_newsletter_recipients r LEFT JOIN tl_member m ON(r.email=m.email) WHERE r.pid=? AND r.active=1 GROUP BY r.email ORDER BY r.email")->limit($intPages, $intStart)->execute($objNewsletter->pid);
echo '<div style="font-family:Verdana,sans-serif;font-size:11px;line-height:16px;margin-bottom:12px">';
// Send newsletter
if ($objRecipients->numRows > 0) {
// Update status
if ($intStart == 0) {
$this->Database->prepare("UPDATE tl_newsletter SET sent=1, date=? WHERE id=?")->execute(time(), $objNewsletter->id);
$_SESSION['REJECTED_RECIPIENTS'] = array();
}
while ($objRecipients->next()) {
$objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
$this->sendNewsletter($objEmail, $objNewsletter, $objRecipients->row(), $text, $html);
echo 'Sending newsletter to <strong>' . $objRecipients->email . '</strong><br>';
//.........这里部分代码省略.........
示例5: splitFriendlyName
/**
* Split a friendly-name e-address and return name and e-mail as array
*
* @param string $strEmail A friendly-name e-mail address
*
* @return array An array with name and e-mail address
*
* @deprecated Use String::splitFriendlyEmail() instead
*/
public static function splitFriendlyName($strEmail)
{
return \String::splitFriendlyEmail($strEmail);
}
示例6: send
/**
* Renturn a form to choose an existing style sheet and import it
* @param \DataContainer
* @return string
*/
public function send(\DataContainer $objDc)
{
if (TL_MODE == 'BE') {
$GLOBALS['TL_CSS'][] = 'system/modules/newsletter_content/assets/css/style.css';
if ($this->isFlexible) {
$GLOBALS['TL_CSS'][] = 'system/modules/newsletter_content/assets/css/style-flexible.css';
}
}
$objNewsletter = $this->Database->prepare("SELECT n.*, c.useSMTP, c.smtpHost, c.smtpPort, c.smtpUser, c.smtpPass FROM tl_newsletter n LEFT JOIN tl_newsletter_channel c ON n.pid=c.id WHERE n.id=?")->limit(1)->execute($objDc->id);
// Return if there is no newsletter
if ($objNewsletter->numRows < 1) {
return '';
}
// Overwrite the SMTP configuration
if ($objNewsletter->useSMTP) {
$GLOBALS['TL_CONFIG']['useSMTP'] = true;
$GLOBALS['TL_CONFIG']['smtpHost'] = $objNewsletter->smtpHost;
$GLOBALS['TL_CONFIG']['smtpUser'] = $objNewsletter->smtpUser;
$GLOBALS['TL_CONFIG']['smtpPass'] = $objNewsletter->smtpPass;
$GLOBALS['TL_CONFIG']['smtpEnc'] = $objNewsletter->smtpEnc;
$GLOBALS['TL_CONFIG']['smtpPort'] = $objNewsletter->smtpPort;
}
// Add default sender address
if ($objNewsletter->sender == '') {
list($objNewsletter->senderName, $objNewsletter->sender) = \String::splitFriendlyEmail($GLOBALS['TL_CONFIG']['adminEmail']);
}
$arrAttachments = array();
$blnAttachmentsFormatError = false;
// Add attachments
if ($objNewsletter->addFile) {
$files = deserialize($objNewsletter->files);
if (!empty($files) && is_array($files)) {
$objFiles = \FilesModel::findMultipleByUuids($files);
if ($objFiles === null) {
if (!\Validator::isUuid($files[0])) {
$blnAttachmentsFormatError = true;
\Message::addError($GLOBALS['TL_LANG']['ERR']['version2format']);
}
} else {
while ($objFiles->next()) {
if (is_file(TL_ROOT . '/' . $objFiles->path)) {
$arrAttachments[] = $objFiles->path;
}
}
}
}
}
// Get content
$html = '';
$objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
if ($objContentElements !== null) {
if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
define('NEWSLETTER_CONTENT_PREVIEW', true);
}
while ($objContentElements->next()) {
$html .= $this->getContentElement($objContentElements->id);
}
}
// Replace insert tags
$text = $this->replaceInsertTags($objNewsletter->text);
$html = $this->replaceInsertTags($html);
// Convert relative URLs
$html = $this->convertRelativeUrls($html);
// Set back to object
$objNewsletter->content = $html;
// Send newsletter
if (!$blnAttachmentsFormatError && \Input::get('token') != '' && \Input::get('token') == $this->Session->get('tl_newsletter_send')) {
$referer = preg_replace('/&(amp;)?(start|mpc|token|recipient|preview)=[^&]*/', '', \Environment::get('request'));
// Preview
if (isset($_GET['preview'])) {
// Check the e-mail address
if (!\Validator::isEmail(\Input::get('recipient', true))) {
$_SESSION['TL_PREVIEW_MAIL_ERROR'] = true;
$this->redirect($referer);
}
// get preview recipient
$arrRecipient = array();
$strEmail = urldecode(\Input::get('recipient', true));
$objRecipient = $this->Database->prepare("SELECT * FROM tl_member m WHERE email=? ORDER BY email")->limit(1)->execute($strEmail);
if ($objRecipient->num_rows < 1) {
$arrRecipient['email'] = $strEmail;
} else {
$arrRecipient = $objRecipient->row();
}
$arrRecipient = array_merge($arrRecipient, array('extra' => '&preview=1', 'tracker_png' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=png', 'tracker_gif' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=gif', 'tracker_css' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=css', 'tracker_js' => \Environment::get('base') . 'tracking/?n=' . $objNewsletter->id . '&e=' . $strEmail . '&preview=1&t=js'));
// Send
$objEmail = $this->generateEmailObject($objNewsletter, $arrAttachments);
$objNewsletter->email = $strEmail;
$this->sendNewsletter($objEmail, $objNewsletter, $arrRecipient, $text, $html);
// Redirect
\Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_newsletter']['confirm'], 1));
$this->redirect($referer);
}
// Get the total number of recipients
$objTotal = $this->Database->prepare("SELECT COUNT(DISTINCT email) AS count FROM tl_newsletter_recipients WHERE pid=? AND active=1")->execute($objNewsletter->pid);
//.........这里部分代码省略.........
示例7: processSubmittedData
//.........这里部分代码省略.........
\Database::getInstance()->prepare("UPDATE tl_formdata %s WHERE id=?")->set($arrUpd)->execute($intNewId);
}
}
// Store data in the session to display on confirmation page
unset($_SESSION['EFP']['FORMDATA']);
$blnSkipEmptyFields = $arrForm['confirmationMailSkipEmpty'] ? true : false;
foreach ($arrFormFields as $k => $arrField) {
$strType = $arrField['formfieldType'];
$strVal = '';
if (in_array($strType, $arrFFstorable)) {
$strVal = $this->Formdata->preparePostValueForMail($arrSubmitted[$k], $arrField, $arrFiles[$k], $blnSkipEmptyFields);
}
$_SESSION['EFP']['FORMDATA'][$k] = $strVal;
}
$_SESSION['EFP']['FORMDATA']['_formId_'] = $arrForm['id'];
// Confirmation Mail
if ($blnFEedit && !$arrForm['sendConfirmationMailOnFrontendEditing']) {
$arrForm['sendConfirmationMail'] = false;
}
if ($arrForm['sendConfirmationMail']) {
$objMailProperties = new \stdClass();
$objMailProperties->subject = '';
$objMailProperties->sender = '';
$objMailProperties->senderName = '';
$objMailProperties->replyTo = '';
$objMailProperties->recipients = array();
$objMailProperties->messageText = '';
$objMailProperties->messageHtmlTmpl = '';
$objMailProperties->messageHtml = '';
$objMailProperties->attachments = array();
$objMailProperties->skipEmptyFields = false;
$objMailProperties->skipEmptyFields = $arrForm['confirmationMailSkipEmpty'] ? true : false;
// Set the sender as given in form configuration
list($senderName, $sender) = \String::splitFriendlyEmail($arrForm['confirmationMailSender']);
$objMailProperties->sender = $sender;
$objMailProperties->senderName = $senderName;
// Set the 'reply to' address, if given in form configuration
if (!empty($arrForm['confirmationMailReplyto'])) {
list($replyToName, $replyTo) = \String::splitFriendlyEmail($arrForm['confirmationMailReplyto']);
$objMailProperties->replyTo = strlen($replyToName) ? $replyToName . ' <' . $replyTo . '>' : $replyTo;
}
// Set recipient(s)
$recipientFieldName = $arrForm['confirmationMailRecipientField'];
$varRecipient = $arrSubmitted[$recipientFieldName];
if (is_array($varRecipient)) {
$arrRecipient = $varRecipient;
} else {
$arrRecipient = trimsplit(',', $varRecipient);
}
if (!empty($arrForm['confirmationMailRecipient'])) {
$varRecipient = $arrForm['confirmationMailRecipient'];
$arrRecipient = array_merge($arrRecipient, trimsplit(',', $varRecipient));
}
$arrRecipient = array_filter(array_unique($arrRecipient));
if (!empty($arrRecipient)) {
foreach ($arrRecipient as $kR => $recipient) {
list($recipientName, $recipient) = \String::splitFriendlyEmail($this->replaceInsertTags($recipient, false));
$arrRecipient[$kR] = strlen($recipientName) ? $recipientName . ' <' . $recipient . '>' : $recipient;
}
}
$objMailProperties->recipients = $arrRecipient;
// Check if we want custom attachments... (Thanks to Torben Schwellnus)
if ($arrForm['addConfirmationMailAttachments']) {
if ($arrForm['confirmationMailAttachments']) {
$arrCustomAttachments = deserialize($arrForm['confirmationMailAttachments'], true);
if (!empty($arrCustomAttachments)) {
示例8: createConfirmationEmail
protected function createConfirmationEmail($arrSubmissionData)
{
$arrRecipient = deserialize($arrSubmissionData[$this->confirmationMailRecipientField]['value'], true);
$objEmail = new \Email();
$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
$objEmail->subject = \String::parseSimpleTokens($this->replaceInsertTags(FormHelper::replaceFormDataTags($this->confirmationMailSubject, $arrSubmissionData), false), $arrSubmissionData);
if ($hasText = strlen($this->confirmationMailText) > 0) {
$objEmail->text = \String::parseSimpleTokens($this->replaceInsertTags(FormHelper::replaceFormDataTags($this->confirmationMailText, $arrSubmissionData), false), $arrSubmissionData);
// convert <br> to new line and strip tags, except links
$objEmail->text = strip_tags(preg_replace('/<br(\\s+)?\\/?>/i', "\n", $objEmail->text), '<a>');
}
if ($this->confirmationMailTemplate != '') {
$objModel = \FilesModel::findByUuid($this->confirmationMailTemplate);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$objFile = new \File($objModel->path, true);
$objEmail->html = \String::parseSimpleTokens($this->replaceInsertTags(FormHelper::replaceFormDataTags($objFile->getContent(), $arrSubmissionData), false), $arrSubmissionData);
// if no text is set, convert html to text
if (!$hasText) {
$objHtml2Text = new \Html2Text\Html2Text($objEmail->html);
$objEmail->text = $objHtml2Text->getText();
}
}
}
// overwrite default from and
if (!empty($this->confirmationMailSender)) {
list($senderName, $sender) = \String::splitFriendlyEmail($this->confirmationMailSender);
$objEmail->from = $this->replaceInsertTags(FormHelper::replaceFormDataTags($sender, $arrSubmissionData), false);
$objEmail->fromName = $this->replaceInsertTags(FormHelper::replaceFormDataTags($senderName, $arrSubmissionData), false);
}
if ($this->confirmationMailAttachment != '') {
$this->addAttachmentToEmail($objEmail, deserialize($this->confirmationMailAttachment));
}
if ($this->sendConfirmationEmail($objEmail, $arrRecipient, $arrSubmissionData)) {
if (is_array($arrRecipient)) {
$arrRecipient = array_filter(array_unique($arrRecipient));
try {
$objEmail->sendTo($arrRecipient);
} catch (Exception $e) {
log_message('Error sending submission email for entity ' . $this->strTable . ':' . $this->intId . ' to : ' . implode(',', $arrRecipient) . ' (' . $e . ')', $this->strLogFile);
}
}
}
}
示例9: compileRecipients
/**
* Generate CC or BCC recipients from comma separated string
* @param string
*/
public static function compileRecipients($strRecipients, $arrTokens)
{
// Replaces tokens first so that tokens can contain a list of recipients.
$strRecipients = static::recursiveReplaceTokensAndTags($strRecipients, $arrTokens, static::NO_TAGS | static::NO_BREAKS);
$arrRecipients = array();
foreach ((array) trimsplit(',', $strRecipients) as $strAddress) {
if ($strAddress != '') {
$strAddress = static::recursiveReplaceTokensAndTags($strAddress, $arrTokens, static::NO_TAGS | static::NO_BREAKS);
list($strName, $strEmail) = \String::splitFriendlyEmail($strAddress);
// Address could become empty through invalid insert tag
if ($strAddress == '' || !\Validator::isEmail($strEmail)) {
continue;
}
$arrRecipients[] = $strAddress;
}
}
return $arrRecipients;
}
示例10: mail
/**
* Send confirmation mail
* @param integer $intID ID of record
* @return string
*/
public function mail($intID = false)
{
$blnSend = false;
if (strlen(\Input::get('token')) && \Input::get('token') == $this->Session->get('fd_mail_send')) {
$blnSend = true;
}
$strFormFilter = $this->strTable == 'tl_formdata' && strlen($this->strFormKey) ? $this->sqlFormFilter : '';
$table_alias = $this->strTable == 'tl_formdata' ? ' f' : '';
if ($intID) {
$this->intId = $intID;
}
$return = '';
$this->values[] = $this->intId;
$this->procedure[] = 'id=?';
$this->blnCreateNewVersion = false;
// Get current record
$sqlQuery = "SELECT * " . (!empty($this->arrSqlDetails) ? ', ' . implode(',', array_values($this->arrSqlDetails)) : '') . " FROM " . $this->strTable . $table_alias;
$sqlWhere = " WHERE id=?";
if ($sqlWhere != '') {
$sqlQuery .= $sqlWhere;
}
$objRow = \Database::getInstance()->prepare($sqlQuery)->limit(1)->execute($this->intId);
// Redirect if there is no record with the given ID
if ($objRow->numRows < 1) {
$this->log('Could not load record "' . $this->strTable . '.id=' . $this->intId . '"', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
}
$arrSubmitted = $objRow->fetchAssoc();
$arrFiles = array();
// Form
$objForm = null;
$intFormId = 0;
if (!empty($GLOBALS['TL_DCA'][$this->strTable]['tl_formdata']['detailFields'])) {
// Try to get the form
foreach ($GLOBALS['TL_DCA'][$this->strTable]['tl_formdata']['detailFields'] as $strField) {
if ($objForm !== null) {
break;
}
if (!empty($GLOBALS['TL_DCA'][$this->strTable]['fields'][$strField]['f_id'])) {
$intFormId = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$strField]['f_id'];
$objForm = \FormModel::findByPk($intFormId);
}
}
}
if ($objForm == null) {
$objForm = \FormModel::findOneBy('title', $arrSubmitted['form']);
}
if ($objForm == null) {
$this->log('Could not load record "tl_form.id=' . $intFormId . '" / "tl_form.title=' . $arrSubmitted['form'] . '"', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
}
$arrForm = $objForm->row();
$arrFormFields = $this->Formdata->getFormfieldsAsArray($arrForm['id']);
if (empty($arrForm['confirmationMailSubject']) || empty($arrForm['confirmationMailText']) && empty($arrForm['confirmationMailTemplate'])) {
return '<p class="tl_error">Can not send this form data record.<br>Missing "Subject", "Text of confirmation mail" or "HTML-template for confirmation mail"<br>Please check configuration of form in form generator.</p>';
}
$this->loadDataContainer('tl_files');
$objMailProperties = new \stdClass();
$objMailProperties->subject = '';
$objMailProperties->sender = '';
$objMailProperties->senderName = '';
$objMailProperties->replyTo = '';
$objMailProperties->recipients = array();
$objMailProperties->messageText = '';
$objMailProperties->messageHtmlTmpl = '';
$objMailProperties->messageHtml = '';
$objMailProperties->attachments = array();
$objMailProperties->skipEmptyFields = false;
$objMailProperties->skipEmptyFields = $arrForm['confirmationMailSkipEmpty'] ? true : false;
$blnStoreOptionsValues = $arrForm['efgStoreValues'] ? true : false;
// Set the sender as given in form configuration
list($senderName, $sender) = \String::splitFriendlyEmail($arrForm['confirmationMailSender']);
$objMailProperties->sender = $sender;
$objMailProperties->senderName = $senderName;
// Set the 'reply to' address, if given in form configuration
if (!empty($arrForm['confirmationMailReplyto'])) {
list($replyToName, $replyTo) = \String::splitFriendlyEmail($arrForm['confirmationMailReplyto']);
$objMailProperties->replyTo = strlen($replyToName) ? $replyToName . ' <' . $replyTo . '>' : $replyTo;
}
// Set recipient(s)
$recipientFieldName = $arrForm['confirmationMailRecipientField'];
if (!empty($recipientFieldName) && !empty($arrSubmitted[$recipientFieldName])) {
$varRecipient = $arrSubmitted[$recipientFieldName];
// handle efg option 'save options of values' for field types radio, select, checkbox
if (in_array($arrFormFields[$recipientFieldName]['type'], array('radio', 'select', 'checkbox'))) {
if (!$blnStoreOptionsValues) {
$arrRecipient = $this->Formdata->prepareDatabaseValueForWidget($varRecipient, $arrFormFields[$recipientFieldName], false);
if (!empty($arrRecipient)) {
$varRecipient = implode(', ', $arrRecipient);
}
unset($arrRecipient);
}
}
$strSep = isset($arrFormFields[$recipientFieldName]['eval']['csv']) ? $arrFormFields[$recipientFieldName]['eval']['csv'] : '|';
$varRecipient = str_replace($strSep, ',', $varRecipient);
//.........这里部分代码省略.........