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


PHP MailUtility::getSystemFrom方法代码示例

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


在下文中一共展示了MailUtility::getSystemFrom方法的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: 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

示例3: sendNotificationEmail

 /**
  * Sends a notification email, reporting system issues.
  *
  * @param array $systemStatus Array of statuses
  */
 protected function sendNotificationEmail(array $systemStatus)
 {
     $systemIssues = array();
     foreach ($systemStatus as $statusProvider) {
         foreach ($statusProvider as $status) {
             if ($status->getSeverity() > \TYPO3\CMS\Reports\Report\Status\Status::OK) {
                 $systemIssues[] = (string) $status;
             }
         }
     }
     $subject = sprintf($GLOBALS['LANG']->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
     $message = sprintf($GLOBALS['LANG']->getLL('status_problemNotification'), '', '');
     $message .= CRLF . CRLF;
     $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
     $message .= CRLF . CRLF;
     $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_issues') . ': ' . CRLF;
     $message .= implode(CRLF, $systemIssues);
     $message .= CRLF . CRLF;
     $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
     $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $mail->setFrom($from);
     $mail->setTo($this->notificationEmail);
     $mail->setSubject($subject);
     $mail->setBody($message);
     $mail->send();
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:31,代码来源:SystemStatusUpdateTask.php

示例4: 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

示例5: sendNotifyEmail

 /**
  * Sends a notification email
  *
  * @param string $message The message content. If blank, no email is sent.
  * @param string $recipients Comma list of recipient email addresses
  * @param string $cc Email address of recipient of an extra mail. The same mail will be sent ONCE more; not using a CC header but sending twice.
  * @param string $senderAddress "From" email address
  * @param string $senderName Optional "From" name
  * @param string $replyTo Optional "Reply-To" header email address.
  * @return boolean Returns TRUE if sent
  */
 public function sendNotifyEmail($message, $recipients, $cc, $senderAddress, $senderName = '', $replyTo = '')
 {
     $result = FALSE;
     /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
     $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $senderName = trim($senderName);
     $senderAddress = trim($senderAddress);
     if ($senderName !== '' && $senderAddress !== '') {
         $sender = array($senderAddress => $senderName);
     } elseif ($senderAddress !== '') {
         $sender = array($senderAddress);
     } else {
         $sender = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
     }
     $mail->setFrom($sender);
     $parsedReplyTo = \TYPO3\CMS\Core\Utility\MailUtility::parseAddresses($replyTo);
     if (count($parsedReplyTo) > 0) {
         $mail->setReplyTo($parsedReplyTo);
     }
     $message = trim($message);
     if ($message !== '') {
         // First line is subject
         $messageParts = explode(LF, $message, 2);
         $subject = trim($messageParts[0]);
         $plainMessage = trim($messageParts[1]);
         $parsedRecipients = \TYPO3\CMS\Core\Utility\MailUtility::parseAddresses($recipients);
         if (count($parsedRecipients) > 0) {
             $mail->setTo($parsedRecipients)->setSubject($subject)->setBody($plainMessage);
             $mail->send();
         }
         $parsedCc = \TYPO3\CMS\Core\Utility\MailUtility::parseAddresses($cc);
         if (count($parsedCc) > 0) {
             /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
             $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
             if (count($parsedReplyTo) > 0) {
                 $mail->setReplyTo($parsedReplyTo);
             }
             $mail->setFrom($sender)->setTo($parsedCc)->setSubject($subject)->setBody($plainMessage);
             $mail->send();
         }
         $result = TRUE;
     }
     return $result;
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:55,代码来源:ContentObjectRenderer.php

示例6: 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

示例7: emailAtLogin

 /**
  * Will send an email notification to warning_email_address/the login users email address when a login session is just started.
  * Depends on various parameters whether mails are send and to whom.
  *
  * @return void
  * @access private
  */
 private function emailAtLogin()
 {
     if ($this->loginSessionStarted) {
         // Send notify-mail
         $subject = 'At "' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '"' . ' from ' . GeneralUtility::getIndpEnv('REMOTE_ADDR') . (GeneralUtility::getIndpEnv('REMOTE_HOST') ? ' (' . GeneralUtility::getIndpEnv('REMOTE_HOST') . ')' : '');
         $msg = sprintf('User "%s" logged in from %s (%s) at "%s" (%s)', $this->user['username'], GeneralUtility::getIndpEnv('REMOTE_ADDR'), GeneralUtility::getIndpEnv('REMOTE_HOST'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], GeneralUtility::getIndpEnv('HTTP_HOST'));
         // Warning email address
         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']) {
             $warn = 0;
             $prefix = '';
             if ((int) $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_mode'] & 1) {
                 // first bit: All logins
                 $warn = 1;
                 $prefix = $this->isAdmin() ? '[AdminLoginWarning]' : '[LoginWarning]';
             }
             if ($this->isAdmin() && (int) $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_mode'] & 2) {
                 // second bit: Only admin-logins
                 $warn = 1;
                 $prefix = '[AdminLoginWarning]';
             }
             if ($warn) {
                 $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
                 /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
                 $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
                 $mail->setTo($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'])->setFrom($from)->setSubject($prefix . ' ' . $subject)->setBody($msg);
                 $mail->send();
             }
         }
         // If An email should be sent to the current user, do that:
         if ($this->uc['emailMeAtLogin'] && strstr($this->user['email'], '@')) {
             $from = \TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom();
             /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
             $mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
             $mail->setTo($this->user['email'])->setFrom($from)->setSubject($subject)->setBody($msg);
             $mail->send();
         }
     }
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:45,代码来源:BackendUserAuthentication.php

示例8: __construct

 /**
  * Create a new Message.
  *
  * Details may be optionally passed into the constructor.
  *
  * @param string $subject
  * @param string $body
  * @param string $contentType
  * @param string $charset
  */
 public function __construct($subject = null, $body = null, $contentType = null, $charset = null)
 {
     parent::__construct($subject, $body, $contentType, $charset);
     $this->setFrom(MailUtility::getSystemFrom());
 }
开发者ID:r3h6,项目名称:TYPO3.EXT.fluidmail,代码行数:15,代码来源:TemplateMailMessage.php

示例9: 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

示例10: createAction

 /**
  * action create
  *
  * @param News $newNews
  * @param string $link
  * @return void
  */
 public function createAction(News $newNews, $link = '')
 {
     $newNews->setDatetime(new \DateTime());
     if (empty($this->settings['enableNewItemsByDefault'])) {
         $newNews->setHidden(1);
     }
     if ($link !== '') {
         $linkObject = new \Tx_News_Domain_Model_Link();
         $linkObject->setUri($link);
         $linkObject->setTitle($link);
         $newNews->addRelatedLink($linkObject);
     }
     // save news
     $this->newsRepository->add($newNews);
     $this->addFlashMessage(LocalizationUtility::translate('news.created', $this->extensionName));
     // send mail
     if ($this->settings['recipientMail']) {
         /** @var $message \TYPO3\CMS\Core\Mail\MailMessage */
         $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
         $from = MailUtility::getSystemFrom();
         $message->setFrom($from)->setTo(array($this->settings['recipientMail'] => 'News Manager'))->setSubject('[New News] ' . $newNews->getTitle())->setBody('<h1>New News</h1>' . $newNews->getBodytext(), 'text/html')->send();
     }
     // clear page cache after save
     if (!$newNews->getHidden()) {
         $this->flushNewsCache($newNews);
     }
     // go to thank you action
     $this->redirect('thankyou');
 }
开发者ID:WebPam,项目名称:TYPO3.newssubmit,代码行数:36,代码来源:NewsController.php

示例11: cleanSender

 /**
  * @param string $templateName
  * @param array $sender
  * @return bool|array
  */
 protected function cleanSender($templateName, array $sender = NULL)
 {
     if ($sender) {
         return $sender;
     }
     if (isset($this->settings['templates'][$templateName]) && isset($this->settings['templates'][$templateName]['sender'])) {
         $senderInfo = $this->settings['templates'][$templateName]['sender'];
         return array($senderInfo['email'] => $senderInfo['name']);
     }
     if ($this->hasDefaultSender()) {
         return $this->defaultSender;
     }
     $systemDefault = MailUtility::getSystemFrom();
     if ($systemDefault) {
         return $systemDefault;
     }
     return FALSE;
 }
开发者ID:electricretina,项目名称:cicbase,代码行数:23,代码来源:EmailService.php

示例12: 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

示例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: sendNotifyEmail

 /**
  * Sends a notification email
  *
  * @param string $message The message content. If blank, no email is sent.
  * @param string $recipients Comma list of recipient email addresses
  * @param string $cc Email address of recipient of an extra mail. The same mail will be sent ONCE more; not using a CC header but sending twice.
  * @param string $senderAddress "From" email address
  * @param string $senderName Optional "From" name
  * @param string $replyTo Optional "Reply-To" header email address.
  * @return bool Returns TRUE if sent
  */
 public function sendNotifyEmail($message, $recipients, $cc, $senderAddress, $senderName = '', $replyTo = '')
 {
     /** @var $mail MailMessage */
     $mail = GeneralUtility::makeInstance(MailMessage::class);
     $senderName = trim($senderName);
     $senderAddress = trim($senderAddress);
     if ($senderName !== '' && $senderAddress !== '') {
         $sender = array($senderAddress => $senderName);
     } elseif ($senderAddress !== '') {
         $sender = array($senderAddress);
     } else {
         $sender = MailUtility::getSystemFrom();
     }
     $mail->setFrom($sender);
     $parsedReplyTo = MailUtility::parseAddresses($replyTo);
     if (!empty($parsedReplyTo)) {
         $mail->setReplyTo($parsedReplyTo);
     }
     $message = trim($message);
     if ($message !== '') {
         // First line is subject
         $messageParts = explode(LF, $message, 2);
         $subject = trim($messageParts[0]);
         $plainMessage = trim($messageParts[1]);
         $parsedRecipients = MailUtility::parseAddresses($recipients);
         if (!empty($parsedRecipients)) {
             $mail->setTo($parsedRecipients)->setSubject($subject)->setBody($plainMessage);
             $mail->send();
         }
         $parsedCc = MailUtility::parseAddresses($cc);
         if (!empty($parsedCc)) {
             /** @var $mail MailMessage */
             $mail = GeneralUtility::makeInstance(MailMessage::class);
             if (!empty($parsedReplyTo)) {
                 $mail->setReplyTo($parsedReplyTo);
             }
             $mail->setFrom($sender)->setTo($parsedCc)->setSubject($subject)->setBody($plainMessage);
             $mail->send();
         }
         return true;
     }
     return false;
 }
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:54,代码来源:ContentObjectRenderer.php

示例15: send

 /**
  * This is the main-function for sending Mails
  *
  * @param array $mailTo
  * @param array $mailFrom
  * @param string $subject
  * @param string $emailBody
  *
  * @return integer the number of recipients who were accepted for delivery
  */
 public function send($mailTo, $mailFrom, $subject, $emailBody)
 {
     if (!($mailTo && is_array($mailTo) && GeneralUtility::validEmail(key($mailTo)))) {
         $this->log->error('Given mailto email address is invalid.', $mailTo);
         return FALSE;
     }
     if (!($mailFrom && is_array($mailFrom) && GeneralUtility::validEmail(key($mailFrom)))) {
         $mailFrom = MailUtility::getSystemFrom();
     }
     /* @var $message \TYPO3\CMS\Core\Mail\MailMessage */
     $message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
     $message->setTo($mailTo)->setFrom($mailFrom)->setSubject($subject)->setCharset(\TYPO3\T3extblog\Utility\GeneralUtility::getTsFe()->metaCharset);
     // send text or html emails
     if (strip_tags($emailBody) === $emailBody) {
         $message->setBody($emailBody, 'text/plain');
     } else {
         $message->setBody($emailBody, 'text/html');
     }
     if (!$this->settings['debug']['disableEmailTransmission']) {
         $message->send();
     }
     $logData = array('mailTo' => $mailTo, 'mailFrom' => $mailFrom, 'subject' => $subject, 'emailBody' => $emailBody, 'isSent' => $message->isSent());
     $this->log->dev('Email sent.', $logData);
     return $logData['isSent'];
 }
开发者ID:dextar1,项目名称:t3extblog,代码行数:35,代码来源:EmailService.php


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