Exemplo n.º 1
0
 /**
  * @test
  */
 public function sendSendsEmail()
 {
     $senderAndRecipient = new Tx_Oelib_Tests_Unit_Fixtures_TestingMailRole('John Doe', '*****@*****.**');
     $eMail = new Tx_Oelib_Mail();
     $eMail->setSender($senderAndRecipient);
     $eMail->addRecipient($senderAndRecipient);
     $eMail->setSubject('Hello world!');
     $eMail->setMessage('Welcome!');
     $this->message->expects(self::once())->method('send');
     $this->subject->send($eMail);
 }
 /**
  * Sends the actual mail and handles autorespond message
  *
  * @return boolean
  */
 public function sendTheMail()
 {
     // Sending the mail requires the recipient and message to be set.
     if (!$this->mailMessage->getTo() || !trim($this->mailMessage->getBody())) {
         return FALSE;
     }
     $this->mailMessage->send();
     // Auto response
     if ($this->autoRespondMessage) {
         $theParts = explode('/', $this->autoRespondMessage, 2);
         $theParts[0] = str_replace('###SUBJECT###', $this->subject, $theParts[0]);
         $theParts[1] = str_replace("/", LF, $theParts[1]);
         $theParts[1] = str_replace("###MESSAGE###", $this->plainContent, $theParts[1]);
         /** @var $autoRespondMail t3lib_mail_Message */
         $autoRespondMail = t3lib_div::makeInstance('t3lib_mail_Message');
         $autoRespondMail->setTo($this->fromAddress)->setSubject($theParts[0])->setFrom($this->recipient)->setBody($theParts[1]);
         $autoRespondMail->send();
     }
     return $this->mailMessage->isSent();
 }
 /**
  * Embeds media into the mail message
  *
  * @param t3lib_mail_Message $mail: mail message
  * @param string $htmlContent: the HTML content of the message
  * @return string the subtituted HTML content
  */
 public function embedMedia(t3lib_mail_Message $mail, $htmlContent)
 {
     $substitutedHtmlContent = $htmlContent;
     $media = array();
     $attribRegex = $this->makeTagRegex(array('img', 'embed', 'audio', 'video'));
     // Split the document by the beginning of the above tags
     $codepieces = preg_split($attribRegex, $htmlContent);
     $len = strlen($codepieces[0]);
     $pieces = count($codepieces);
     $reg = array();
     for ($i = 1; $i < $pieces; $i++) {
         $tag = strtolower(strtok(substr($htmlContent, $len + 1, 10), ' '));
         $len += strlen($tag) + strlen($codepieces[$i]) + 2;
         $dummy = preg_match('/[^>]*/', $codepieces[$i], $reg);
         // Fetches the attributes for the tag
         $attributes = $this->getTagAttributes($reg[0]);
         if ($attributes['src']) {
             $media[] = $attributes['src'];
         }
     }
     foreach ($media as $key => $source) {
         $substitutedHtmlContent = str_replace('"' . $source . '"', '"' . $mail->embed(Swift_Image::fromPath($source)) . '"', $substitutedHtmlContent);
     }
     return $substitutedHtmlContent;
 }
Exemplo n.º 4
0
 /**
  * Initializes the message instance.
  *
  * @param t3lib_mail_Message $object TYPO3 mail object
  * @param string $charset Default charset of the message
  */
 public function __construct(t3lib_mail_Message $object, $charset)
 {
     $object->setCharset($charset);
     $this->_object = $object;
 }
Exemplo n.º 5
0
 /**
  * Sends a Swift e-mail.
  *
  * @param t3lib_mail_Message $email the e-mail to send.
  *
  * @return void
  */
 protected function sendSwiftMail(t3lib_mail_Message $email)
 {
     $email->send();
 }