当前位置: 首页>>代码示例>>PHP>>正文


PHP Utility\MailUtility类代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\MailUtility的典型用法代码示例。如果您正苦于以下问题:PHP MailUtility类的具体用法?PHP MailUtility怎么用?PHP MailUtility使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MailUtility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendEmail

 /**
  * Send a email using t3lib_htmlmail or the new swift mailer
  * It depends on the TYPO3 version
  */
 public static function sendEmail($to, $subject, $message, $type = 'plain', $charset = 'utf-8', $files = array())
 {
     $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $mail->setTo(explode(',', $to));
     $mail->setSubject($subject);
     $mail->setCharset($charset);
     $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
     $mail->setFrom($from);
     $mail->setReplyTo($from);
     // add Files
     if (!empty($files)) {
         foreach ($files as $file) {
             $mail->attach(Swift_Attachment::fromPath($file));
         }
     }
     // add Plain
     if ($type == 'plain') {
         $mail->addPart($message, 'text/plain');
     }
     // add HTML
     if ($type == 'html') {
         $mail->setBody($message, 'text/html');
     }
     // send
     $mail->send();
 }
开发者ID:Apen,项目名称:additional_scheduler,代码行数:30,代码来源:Utils.php

示例2: injectConfigurationManager

 /**
  * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
  * @return void
  */
 public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
 {
     parent::injectConfigurationManager($configurationManager);
     $defaultSettings = array('dateFormat' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], 'login' => array('page' => $this->getFrontendController()->id), 'passwordReset' => array('loginOnSuccess' => FALSE, 'mail' => array('from' => MailUtility::getSystemFromAddress(), 'subject' => 'Password reset request'), 'page' => $this->getFrontendController()->id, 'token' => array('lifetime' => 86400)));
     $settings = $defaultSettings;
     ArrayUtility::mergeRecursiveWithOverrule($settings, $this->settings, TRUE, FALSE);
     $this->settings = $settings;
 }
开发者ID:mjankiewicz,项目名称:hairu,代码行数:12,代码来源:AuthenticationController.php

示例3: sendNotification

 /**
  * @param array $from  array('email' => '', 'name' => '')
  * @param array $to array('email' => '', 'name' => '')
  * @param $subject
  * @param $body
  * @return boolean
  */
 public static function sendNotification(array $from, array $to, $subject, $body)
 {
     if (!count($from)) {
         $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
     }
     $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     return $mail->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setSubject($subject)->setBody($body)->send();
 }
开发者ID:kj187,项目名称:paypal,代码行数:15,代码来源:Notification.php

示例4: initializeAction

 /**
  * Initialize all actions
  *
  * @return void
  */
 protected function initializeAction()
 {
     // Apply default settings
     $defaultSettings = array('dateFormat' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], 'login' => array('page' => $this->getFrontendController()->id), 'passwordReset' => array('loginOnSuccess' => FALSE, 'mail' => array('from' => MailUtility::getSystemFromAddress(), 'subject' => 'Password reset request'), 'page' => $this->getFrontendController()->id, 'token' => array('lifetime' => 86400)));
     $settings = $defaultSettings;
     ArrayUtility::mergeRecursiveWithOverrule($settings, $this->settings, TRUE, FALSE);
     $this->settings = $settings;
     // Make global form data (as expected by the CMS core) available
     $formData = GeneralUtility::_GET();
     ArrayUtility::mergeRecursiveWithOverrule($formData, GeneralUtility::_POST());
     $this->request->setArgument('formData', $formData);
 }
开发者ID:pagemachine,项目名称:hairu,代码行数:17,代码来源:AuthenticationController.php

示例5: renderInternal

 /**
  * Render the given element
  *
  * @return array
  */
 public function renderInternal()
 {
     $headerWrap = MailUtility::breakLinesForEmail(trim($this->contentObject->data['header']), LF, Configuration::getPlainTextWith());
     $subHeaderWrap = MailUtility::breakLinesForEmail(trim($this->contentObject->data['subheader']), LF, Configuration::getPlainTextWith());
     // align
     $header = array_merge(GeneralUtility::trimExplode(LF, $headerWrap, TRUE), GeneralUtility::trimExplode(LF, $subHeaderWrap, TRUE));
     if ($this->contentObject->data['header_position'] == 'right') {
         foreach ($header as $key => $l) {
             $l = trim($l);
             $header[$key] = str_pad(' ', Configuration::getPlainTextWith() - strlen($l), ' ', STR_PAD_LEFT) . $l;
         }
     } elseif ($this->contentObject->data['header_position'] == 'center') {
         foreach ($header as $key => $l) {
             $l = trim($l);
             $header[$key] = str_pad(' ', floor((Configuration::getPlainTextWith() - strlen($l)) / 2), ' ', STR_PAD_LEFT) . $l;
         }
     }
     $header = implode(LF, $header);
     $lines[] = $header;
     return $lines;
 }
开发者ID:ercuement,项目名称:ink,代码行数:26,代码来源:Header.php

示例6: sysLog

 /**
  * Logs message to the system log.
  * This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
  * If you want to implement the sysLog in your applications, simply add lines like:
  * \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('[write message in English here]', 'extension_key', 'severity');
  *
  * @param string $msg Message (in English).
  * @param string $extKey Extension key (from which extension you are calling the log) or "Core
  * @param integer $severity \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_* constant
  * @return void
  */
 public static function sysLog($msg, $extKey, $severity = 0)
 {
     $severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, 0, 4);
     // Is message worth logging?
     if ((int) $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] > $severity) {
         return;
     }
     // Initialize logging
     if (!$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) {
         self::initSysLog();
     }
     // Do custom logging
     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
         $params = array('msg' => $msg, 'extKey' => $extKey, 'backTrace' => debug_backtrace(), 'severity' => $severity);
         $fakeThis = FALSE;
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
             self::callUserFunction($hookMethod, $params, $fakeThis);
         }
     }
     // TYPO3 logging enabled?
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog']) {
         return;
     }
     $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
     $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
     // Use all configured logging options
     foreach (explode(';', $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'], 2) as $log) {
         list($type, $destination, $level) = explode(',', $log, 4);
         // Is message worth logging for this log type?
         if ((int) $level > $severity) {
             continue;
         }
         $msgLine = ' - ' . $extKey . ': ' . $msg;
         // Write message to a file
         if ($type == 'file') {
             $file = fopen($destination, 'a');
             if ($file) {
                 fwrite($file, date($dateFormat . ' ' . $timeFormat) . $msgLine . LF);
                 fclose($file);
                 self::fixPermissions($destination);
             }
         } elseif ($type == 'mail') {
             list($to, $from) = explode('/', $destination);
             if (!self::validEmail($from)) {
                 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
             }
             /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
             $mail = self::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
             $mail->setTo($to)->setFrom($from)->setSubject('Warning - error in TYPO3 installation')->setBody('Host: ' . $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . LF . 'Extension: ' . $extKey . LF . 'Severity: ' . $severity . LF . LF . $msg);
             $mail->send();
         } elseif ($type == 'error_log') {
             error_log($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0);
         } elseif ($type == 'syslog') {
             $priority = array(LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT);
             syslog($priority[(int) $severity], $msgLine);
         }
     }
 }
开发者ID:KarlDennisMatthaei1923,项目名称:PierraaDesign,代码行数:69,代码来源:GeneralUtility.php

示例7: reportEmail

 /**
  * Build and send warning email when new broken links were found
  *
  * @param string $pageSections Content of page section
  * @param array $modTsConfig TSconfig array
  * @return bool TRUE if mail was sent, FALSE if or not
  * @throws \Exception if required modTsConfig settings are missing
  */
 protected function reportEmail($pageSections, array $modTsConfig)
 {
     $content = $this->templateService->substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
     /** @var array $markerArray */
     $markerArray = array();
     /** @var array $validEmailList */
     $validEmailList = array();
     /** @var bool $sendEmail */
     $sendEmail = true;
     $markerArray['totalBrokenLink'] = $this->totalBrokenLink;
     $markerArray['totalBrokenLink_old'] = $this->oldTotalBrokenLink;
     // Hook
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['reportEmailMarkers'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['reportEmailMarkers'] as $userFunc) {
             $params = array('pObj' => &$this, 'markerArray' => $markerArray);
             $newMarkers = GeneralUtility::callUserFunction($userFunc, $params, $this);
             if (is_array($newMarkers)) {
                 $markerArray = $newMarkers + $markerArray;
             }
             unset($params);
         }
     }
     $content = $this->templateService->substituteMarkerArray($content, $markerArray, '###|###', true, true);
     /** @var $mail MailMessage */
     $mail = GeneralUtility::makeInstance(MailMessage::class);
     if (empty($modTsConfig['mail.']['fromemail'])) {
         $modTsConfig['mail.']['fromemail'] = MailUtility::getSystemFromAddress();
     }
     if (empty($modTsConfig['mail.']['fromname'])) {
         $modTsConfig['mail.']['fromname'] = MailUtility::getSystemFromName();
     }
     if (GeneralUtility::validEmail($modTsConfig['mail.']['fromemail'])) {
         $mail->setFrom(array($modTsConfig['mail.']['fromemail'] => $modTsConfig['mail.']['fromname']));
     } else {
         throw new \Exception($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidFromEmail'), '1295476760');
     }
     if (GeneralUtility::validEmail($modTsConfig['mail.']['replytoemail'])) {
         $mail->setReplyTo(array($modTsConfig['mail.']['replytoemail'] => $modTsConfig['mail.']['replytoname']));
     }
     if (!empty($modTsConfig['mail.']['subject'])) {
         $mail->setSubject($modTsConfig['mail.']['subject']);
     } else {
         throw new \Exception($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.noSubject'), '1295476808');
     }
     if (!empty($this->email)) {
         // Check if old input field value is still there and save the value a
         if (strpos($this->email, ',') !== false) {
             $emailList = GeneralUtility::trimExplode(',', $this->email, true);
             $this->email = implode(LF, $emailList);
             $this->save();
         } else {
             $emailList = GeneralUtility::trimExplode(LF, $this->email, true);
         }
         foreach ($emailList as $emailAdd) {
             if (!GeneralUtility::validEmail($emailAdd)) {
                 throw new \Exception($this->getLanguageService()->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidToEmail'), '1295476821');
             } else {
                 $validEmailList[] = $emailAdd;
             }
         }
     }
     if (is_array($validEmailList) && !empty($validEmailList)) {
         $mail->setTo($validEmailList);
     } else {
         $sendEmail = false;
     }
     if ($sendEmail) {
         $mail->setBody($content, 'text/html');
         $mail->send();
     }
     return $sendEmail;
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:80,代码来源:ValidatorTask.php

示例8: notifyStageChange


//.........这里部分代码省略.........
        } else {
            $emails = $notificationAlternativeRecipients;
        }
        // prepare and then send the emails
        if (count($emails)) {
            // Path to record is found:
            list($elementTable, $elementUid) = explode(':', $elementName);
            $elementUid = (int) $elementUid;
            $elementRecord = BackendUtility::getRecord($elementTable, $elementUid);
            $recordTitle = BackendUtility::getRecordTitle($elementTable, $elementRecord);
            if ($elementTable == 'pages') {
                $pageUid = $elementUid;
            } else {
                BackendUtility::fixVersioningPid($elementTable, $elementRecord);
                $pageUid = $elementUid = $elementRecord['pid'];
            }
            // fetch the TSconfig settings for the email
            // old way, options are TCEMAIN.notificationEmail_body/subject
            $TCEmainTSConfig = $tcemainObj->getTCEMAIN_TSconfig($pageUid);
            // new way, options are
            // pageTSconfig: tx_version.workspaces.stageNotificationEmail.subject
            // userTSconfig: page.tx_version.workspaces.stageNotificationEmail.subject
            $pageTsConfig = BackendUtility::getPagesTSconfig($pageUid);
            $emailConfig = $pageTsConfig['tx_version.']['workspaces.']['stageNotificationEmail.'];
            $markers = array('###RECORD_TITLE###' => $recordTitle, '###RECORD_PATH###' => BackendUtility::getRecordPath($elementUid, '', 20), '###SITE_NAME###' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], '###SITE_URL###' => GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, '###WORKSPACE_TITLE###' => $workspaceRec['title'], '###WORKSPACE_UID###' => $workspaceRec['uid'], '###ELEMENT_NAME###' => $elementName, '###NEXT_STAGE###' => $newStage, '###COMMENT###' => $comment, '###USER_REALNAME###' => $tcemainObj->BE_USER->user['realName'], '###USER_FULLNAME###' => $tcemainObj->BE_USER->user['realName'], '###USER_USERNAME###' => $tcemainObj->BE_USER->user['username']);
            // add marker for preview links if workspace extension is loaded
            if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
                $this->workspaceService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
                // only generate the link if the marker is in the template - prevents database from getting to much entries
                if (GeneralUtility::isFirstPartOfStr($emailConfig['message'], 'LLL:')) {
                    $tempEmailMessage = $GLOBALS['LANG']->sL($emailConfig['message']);
                } else {
                    $tempEmailMessage = $emailConfig['message'];
                }
                if (strpos($tempEmailMessage, '###PREVIEW_LINK###') !== FALSE) {
                    $markers['###PREVIEW_LINK###'] = $this->workspaceService->generateWorkspacePreviewLink($elementUid);
                }
                unset($tempEmailMessage);
                $markers['###SPLITTED_PREVIEW_LINK###'] = $this->workspaceService->generateWorkspaceSplittedPreviewLink($elementUid, TRUE);
            }
            // Hook for preprocessing of the content for formmails:
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/version/class.tx_version_tcemain.php']['notifyStageChange-postModifyMarkers'])) {
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/version/class.tx_version_tcemain.php']['notifyStageChange-postModifyMarkers'] as $_classRef) {
                    $_procObj =& GeneralUtility::getUserObj($_classRef);
                    $markers = $_procObj->postModifyMarkers($markers, $this);
                }
            }
            // send an email to each individual user, to ensure the
            // multilanguage version of the email
            $emailRecipients = array();
            // an array of language objects that are needed
            // for emails with different languages
            $languageObjects = array($GLOBALS['LANG']->lang => $GLOBALS['LANG']);
            // loop through each recipient and send the email
            foreach ($emails as $recipientData) {
                // don't send an email twice
                if (isset($emailRecipients[$recipientData['email']])) {
                    continue;
                }
                $emailSubject = $emailConfig['subject'];
                $emailMessage = $emailConfig['message'];
                $emailRecipients[$recipientData['email']] = $recipientData['email'];
                // check if the email needs to be localized
                // in the users' language
                if (GeneralUtility::isFirstPartOfStr($emailSubject, 'LLL:') || GeneralUtility::isFirstPartOfStr($emailMessage, 'LLL:')) {
                    $recipientLanguage = $recipientData['lang'] ? $recipientData['lang'] : 'default';
                    if (!isset($languageObjects[$recipientLanguage])) {
                        // a LANG object in this language hasn't been
                        // instantiated yet, so this is done here
                        /** @var $languageObject \TYPO3\CMS\Lang\LanguageService */
                        $languageObject = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
                        $languageObject->init($recipientLanguage);
                        $languageObjects[$recipientLanguage] = $languageObject;
                    } else {
                        $languageObject = $languageObjects[$recipientLanguage];
                    }
                    if (GeneralUtility::isFirstPartOfStr($emailSubject, 'LLL:')) {
                        $emailSubject = $languageObject->sL($emailSubject);
                    }
                    if (GeneralUtility::isFirstPartOfStr($emailMessage, 'LLL:')) {
                        $emailMessage = $languageObject->sL($emailMessage);
                    }
                }
                $emailSubject = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
                $emailMessage = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
                // Send an email to the recipient
                /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
                $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
                if (!empty($recipientData['realName'])) {
                    $recipient = array($recipientData['email'] => $recipientData['realName']);
                } else {
                    $recipient = $recipientData['email'];
                }
                $mail->setTo($recipient)->setSubject($emailSubject)->setFrom(\TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom())->setBody($emailMessage);
                $mail->send();
            }
            $emailRecipients = implode(',', $emailRecipients);
            $tcemainObj->newlog2('Notification email for stage change was sent to "' . $emailRecipients . '"', $table, $id);
        }
    }
开发者ID:adrolli,项目名称:TYPO3.CMS,代码行数:101,代码来源:DataHandlerHook.php

示例9: setFrom

 /**
  * Sets the sender of the mail message
  *
  * Mostly the sender is a combination of the name and the email address
  *
  * @return void
  */
 protected function setFrom()
 {
     $fromEmail = '';
     if ($this->typoScript['senderEmail']) {
         $fromEmail = $this->typoScript['senderEmail'];
     } elseif ($this->requestHandler->has($this->typoScript['senderEmailField'])) {
         $fromEmail = $this->requestHandler->get($this->typoScript['senderEmailField']);
     } else {
         $fromEmail = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
     }
     if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($fromEmail)) {
         $fromEmail = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFromAddress();
     }
     $fromName = '';
     if ($this->typoScript['senderName']) {
         $fromName = $this->typoScript['senderName'];
     } elseif ($this->requestHandler->has($this->typoScript['senderNameField'])) {
         $fromName = $this->requestHandler->get($this->typoScript['senderNameField']);
     } else {
         $fromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'];
     }
     $fromName = $this->sanitizeHeaderString($fromName);
     if (preg_match('/\\s|,/', $fromName) >= 1) {
         $fromName = '"' . $fromName . '"';
     }
     $from = array($fromEmail => $fromName);
     $this->mailMessage->setFrom($from);
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:35,代码来源:MailPostProcessor.php

示例10: sendNotificationEmail

 /**
  * Sends a notification email, reporting system issues.
  *
  * @param Status[] $systemStatus Array of statuses
  * @return void
  */
 protected function sendNotificationEmail(array $systemStatus)
 {
     $systemIssues = array();
     foreach ($systemStatus as $statusProvider) {
         /** @var Status $status */
         foreach ($statusProvider as $status) {
             if ($status->getSeverity() > Status::OK) {
                 $systemIssues[] = (string) $status . CRLF . $status->getMessage() . CRLF . CRLF;
             }
         }
     }
     $notificationEmails = GeneralUtility::trimExplode(LF, $this->notificationEmail, true);
     $sendEmailsTo = array();
     foreach ($notificationEmails as $notificationEmail) {
         $sendEmailsTo[] = $notificationEmail;
     }
     $subject = sprintf($this->getLanguageService()->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
     $message = sprintf($this->getLanguageService()->getLL('status_problemNotification'), '', '');
     $message .= CRLF . CRLF;
     $message .= $this->getLanguageService()->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
     $message .= CRLF . CRLF;
     $message .= $this->getLanguageService()->getLL('status_updateTask_email_issues') . ': ' . CRLF;
     $message .= implode(CRLF, $systemIssues);
     $message .= CRLF . CRLF;
     $from = MailUtility::getSystemFrom();
     /** @var MailMessage $mail */
     $mail = GeneralUtility::makeInstance(MailMessage::class);
     $mail->setFrom($from);
     $mail->setTo($sendEmailsTo);
     $mail->setSubject($subject);
     $mail->setBody($message);
     $mail->send();
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:39,代码来源:SystemStatusUpdateTask.php

示例11: updateStatusMail

 /**
  * @param Model\Project $project
  * @param array         $receivers
  * @param bool          $isAccepted
  */
 public function updateStatusMail(Model\Project $project, array $receivers = [], $isAccepted = true)
 {
     $noReply = null;
     if ($this->settings['mail']['noReplyEmail'] && CoreUtility\GeneralUtility::validEmail($this->settings['mail']['noReplyEmail'])) {
         $noReply = [$this->settings['mail']['noReplyEmail'] => $this->settings['mail']['noReplyName'] ?: $this->settings['mail']['senderName']];
     }
     $carbonCopyReceivers = [];
     if ($this->settings['mail']['carbonCopy']) {
         foreach (explode(',', $this->settings['mail']['carbonCopy']) as $carbonCopyReceiver) {
             $tokens = CoreUtility\GeneralUtility::trimExplode(' ', $carbonCopyReceiver, true, 2);
             if (CoreUtility\GeneralUtility::validEmail($tokens[0])) {
                 $carbonCopyReceivers[$tokens[0]] = $tokens[1];
             }
         }
     }
     /** @var \TYPO3\CMS\Core\Mail\MailMessage $mailToSender */
     $mailToSender = CoreUtility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
     $mailToSender->setContentType('text/html');
     /**
      * Email to sender
      */
     $mailToSender->setFrom($noReply ?: CoreUtility\MailUtility::getSystemFrom())->setTo([$project->getRegistrant()->getEmail() => $project->getRegistrant()->getName()])->setCc($receivers)->setSubject(($this->settings['mail']['projectStatusUpdateSubject'] ?: (Lang::translate('mail_project_status_update_subject', $this->extensionName) ?: 'Project status update')) . " #{$project->getUid()}")->setBody($this->getStandAloneTemplate(CoreUtility\ExtensionManagementUtility::siteRelPath(CoreUtility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName)) . 'Resources/Private/Templates/Email/ProjectStatusUpdated.html', ['settings' => $this->settings, 'project' => $project, 'accepted' => $isAccepted, 'addressees' => $this->getAddressees()]))->send();
 }
开发者ID:S3b0,项目名称:project_registration,代码行数:28,代码来源:ProjectController.php

示例12: breakLines

 /**
  * Breaking lines into fixed length lines, using MailUtility::breakLinesForEmail()
  *
  * @param	string		$str: The string to break
  * @param	string		$implChar: Line break character
  * @param	integer		$charWidth: Length of lines, default is $this->charWidth
  * @return	string		Processed string
  * @see MailUtility::breakLinesForEmail()
  */
 function breakLines($str, $implChar, $charWidth = 0)
 {
     $cW = $charWidth ? $charWidth : $this->charWidth;
     $linebreak = $implChar ? $implChar : $this->linebreak;
     return MailUtility::breakLinesForEmail($str, $linebreak, $cW);
 }
开发者ID:preinboth,项目名称:direct_mail,代码行数:15,代码来源:class.tx_directmail_pi1.php

示例13: sendNotification

 /**
  * Sends a notification email
  *
  * @param  string     $recipients  comma-separated list of email addresses that should
  *                                 receive the notification
  * @param  array      $config      notification configuration
  * @param  object     $media       one or multiple media records (QueryResult)
  * @param  \Exception $exception   the exception that was thrown
  * @return boolean                 success status of email
  */
 protected function sendNotification($recipients, array $config, $media, \Exception $exception = NULL)
 {
     // Convert comma-separated list to array
     $recipients = array_map('trim', explode(',', $recipients));
     // Generate markers for the email subject and content
     $markers = array('###SIGNATURE###' => $config['signature']);
     if (isset($exception)) {
         $markers['###ERROR###'] = $exception->getMessage();
         $markers['###ERROR_FILE###'] = $exception->getFile();
         $markers['###ERROR_LINE###'] = $exception->getLine();
     }
     // Generate list of media files for the email
     $allMedia = $media instanceof Media ? array($media) : $media->toArray();
     $mediaFiles = array();
     foreach ($allMedia as $oneMedia) {
         // Get all properties of media record that can be outputted
         $mediaMarkers = array();
         foreach ($oneMedia->toArray() as $key => $value) {
             if (!is_object($value)) {
                 $mediaMarkers[$key] = $value;
             }
         }
         // Provide properties as markers
         $mediaFiles[] = $this->cObj->substituteMarkerArray($config['mediafiles'], $mediaMarkers, '###|###', TRUE);
     }
     $markers['###MEDIAFILES###'] = implode("\n", $mediaFiles);
     // Replace markers in subject and content
     $subject = $this->cObj->substituteMarkerArray($config['subject'], $markers);
     $message = $this->cObj->substituteMarkerArray($config['message'], $markers);
     // Send email
     return $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage')->setFrom(\TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom())->setTo($recipients)->setSubject($subject)->setBody($message)->send();
 }
开发者ID:lokamaya,项目名称:html5mediaelements,代码行数:42,代码来源:OptimizeMediaCommandController.php

示例14: reportEmail

 /**
  * Build and send warning email when new broken links were found
  *
  * @param string $pageSections Content of page section
  * @param array $modTsConfig TSconfig array
  * @return boolean TRUE if mail was sent, FALSE if or not
  * @throws \Exception if required modTsConfig settings are missing
  */
 protected function reportEmail($pageSections, array $modTsConfig)
 {
     $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
     /** @var array $markerArray */
     $markerArray = array();
     /** @var array $validEmailList */
     $validEmailList = array();
     /** @var boolean $sendEmail */
     $sendEmail = TRUE;
     $markerArray['totalBrokenLink'] = $this->totalBrokenLink;
     $markerArray['totalBrokenLink_old'] = $this->oldTotalBrokenLink;
     // Hook
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['reportEmailMarkers'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['reportEmailMarkers'] as $userFunc) {
             $params = array('pObj' => &$this, 'markerArray' => $markerArray);
             $newMarkers = GeneralUtility::callUserFunction($userFunc, $params, $this);
             if (is_array($newMarkers)) {
                 $markerArray = GeneralUtility::array_merge($markerArray, $newMarkers);
             }
             unset($params);
         }
     }
     $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
     /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
     $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     if (empty($modTsConfig['mail.']['fromemail'])) {
         $modTsConfig['mail.']['fromemail'] = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFromAddress();
     }
     if (empty($modTsConfig['mail.']['fromname'])) {
         $modTsConfig['mail.']['fromname'] = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFromName();
     }
     if (GeneralUtility::validEmail($modTsConfig['mail.']['fromemail'])) {
         $mail->setFrom(array($modTsConfig['mail.']['fromemail'] => $modTsConfig['mail.']['fromname']));
     } else {
         throw new \Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidFromEmail'), '1295476760');
     }
     if (GeneralUtility::validEmail($modTsConfig['mail.']['replytoemail'])) {
         $mail->setReplyTo(array($modTsConfig['mail.']['replytoemail'] => $modTsConfig['mail.']['replytoname']));
     }
     if (!empty($modTsConfig['mail.']['subject'])) {
         $mail->setSubject($modTsConfig['mail.']['subject']);
     } else {
         throw new \Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.noSubject'), '1295476808');
     }
     if (!empty($this->email)) {
         $emailList = GeneralUtility::trimExplode(',', $this->email);
         foreach ($emailList as $emailAdd) {
             if (!GeneralUtility::validEmail($emailAdd)) {
                 throw new \Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:tasks.error.invalidToEmail'), '1295476821');
             } else {
                 $validEmailList[] = $emailAdd;
             }
         }
     }
     if (is_array($validEmailList) && !empty($validEmailList)) {
         $mail->setTo($validEmailList);
     } else {
         $sendEmail = FALSE;
     }
     if ($sendEmail) {
         $mail->setBody($content, 'text/html');
         $mail->send();
     }
     return $sendEmail;
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:73,代码来源:ValidatorTask.php

示例15: mailAction

 /**
  * @param  array  $msg
  * @return string
  */
 public function mailAction(array $msg = array())
 {
     $recipient = $this->widgetConfiguration['recipient'];
     $sender = $this->widgetConfiguration['sender'];
     $required = $this->widgetConfiguration['required'];
     $missing = array();
     /* example: $required = [ 'name', 'email,phone' ] => name and (phone or email) are required.*/
     foreach ($required as $orFieldList) {
         $orFields = explode(',', $orFieldList);
         $found = false;
         foreach ($orFields as $field) {
             if (array_key_exists($field, $msg) && strlen($msg[$field]) != 0) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             foreach ($orFields as $field) {
                 $missing[] = $field;
             }
         }
     }
     if (count($missing)) {
         return json_encode(array('status' => 'fields-missing', 'missing' => $missing));
     }
     if (!is_array($recipient) || !array_key_exists('email', $recipient)) {
         /* TODO: Throw exception instead. */
         return json_encode(array('status' => 'internal-error', 'error' => '$recipient is not valid'));
     }
     if (isset($recipient['name']) && strlen($recipient['name']) > 0) {
         $tmp = $recipient;
         $recipient = array();
         foreach (GeneralUtility::trimExplode(',', $tmp['email']) as $email) {
             $recipient[$email] = $tmp['name'];
         }
     } else {
         $recipient = GeneralUtility::trimExplode(',', $recipient['email']);
     }
     $sender = $sender !== null ? array($sender['email'] => $sender['name']) : MailUtility::getSystemFrom();
     $recipientSave = $recipient;
     $recipientOverwrite = $this->widgetConfiguration['receiver_overwrite_email'];
     if ($recipientOverwrite !== null) {
         $recipient = $recipientOverwrite;
     }
     $params = array('to' => $recipient, 'from' => $sender, 'msg' => $msg);
     $view = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($this->widgetConfiguration['mailTemplate']));
     $view->assignMultiple($params);
     $text = $view->render();
     list($subject, $body) = explode("\n", $text, 2);
     if ($recipientOverwrite !== null) {
         $subject .= ' – Recipient: ' . implode(',', $recipientSave);
     }
     $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $mail->setFrom($sender);
     $mail->setTo($recipient);
     $mail->setSubject($subject);
     $mail->setBody(trim($body));
     if (isset($msg['email']) && strlen($msg['email']) > 0) {
         $mail->setReplyTo($msg['email']);
     }
     $mail->send();
     return json_encode(array('status' => 'ok'));
 }
开发者ID:qbus-agentur,项目名称:qbtools,代码行数:68,代码来源:MailformController.php


注:本文中的TYPO3\CMS\Core\Utility\MailUtility类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。