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


PHP MailUtility::parseAddresses方法代码示例

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


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

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

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

示例3: parseAddressesTest

 /**
  * @test
  * @dataProvider parseAddressesProvider
  */
 public function parseAddressesTest($source, $addressList)
 {
     $returnArray = \TYPO3\CMS\Core\Utility\MailUtility::parseAddresses($source);
     $this->assertEquals($addressList, $returnArray);
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:9,代码来源:MailUtilityTest.php


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