Пример #1
0
 /**
  * send lost password mail
  *
  * @param   string $_username
  * @return  bool
  * 
  * @todo    add more texts to mail views & translate mails
  */
 public function sendLostPasswordMail($_username)
 {
     // get full user
     $fullAccount = Tinebase_User::getInstance()->getFullUserByLoginName($_username);
     // generate new password
     $newPassword = $this->generatePassword();
     // save new password in user
     Tinebase_Auth::getInstance()->setPassword($_username, $newPassword, $newPassword);
     // send lost password mail
     $mail = new Tinebase_Mail('UTF-8');
     $mail->setSubject("New password for Tine 2.0");
     // get name from user
     //$recipientName = $fullAccount->accountFirstName." ".$fullAccount->accountLastName;
     $recipientName = $fullAccount->accountFullName;
     // get email from user
     $recipientEmail = $fullAccount->accountEmailAddress;
     // get plain and html message from views
     //-- translate text and insert correct link
     $view = new Zend_View();
     $view->setScriptPath(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'views');
     $view->mailTextWelcome = "We generated a new password for you ...";
     $view->newPassword = $newPassword;
     $messagePlain = $view->render('lostpwMailPlain.php');
     $mail->setBodyText($messagePlain);
     $messageHtml = $view->render('lostpwMailHtml.php');
     if ($messageHtml !== NULL) {
         $mail->setBodyHtml($messageHtml);
     }
     $mail->addHeader('X-MailGenerator', 'Tine 2.0');
     $mail->setFrom('*****@*****.**', 'Tine 2.0 Webmaster');
     if (!empty($recipientEmail)) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' send lost password email to ' . $recipientEmail);
         }
         $mail->addTo($recipientEmail, $recipientName);
         $mail->send();
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * test line end encoding of Zend_Mime_Part / Smtp Protocol
  */
 public function testSendWithWrongLineEnd()
 {
     $config = TestServer::getInstance()->getConfig();
     $mailDomain = $config->maildomain ? $config->maildomain : 'tine20.org';
     // build message with wrong line end rfc822 part
     $mail = new Tinebase_Mail('utf-8');
     $mail->setBodyText('testmail' . "\r\n" . "\r\n");
     $mail->setFrom('unittest@' . $mailDomain, 'unittest');
     $mail->setSubject('line end test');
     $mail->addTo('unittest@' . $mailDomain);
     $mail->addHeader('X-Tine20TestMessage', 'lineend');
     // replace EOLs
     $content = file_get_contents(dirname(dirname(__FILE__)) . '/files/text_plain.eml');
     $content = preg_replace("/\\x0a/", "\r\n", $content);
     $stream = fopen("php://temp", 'r+');
     fputs($stream, $content);
     rewind($stream);
     $attachment = new Zend_Mime_Part($stream);
     $attachment->type = Felamimail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822;
     $attachment->encoding = null;
     $attachment->charset = 'ISO-8859-1';
     $attachment->filename = 'attach.eml';
     $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
     $mail->addAttachment($attachment);
     $smtpConfig = $this->_account->getSmtpConfig();
     $transport = new Felamimail_Transport($smtpConfig['hostname'], $smtpConfig);
     $mail->send($transport);
     $smtpLog = $transport->getConnection()->getLog();
     $badLineEndCount = preg_match_all("/\\x0d\\x0d\\x0a/", $smtpLog, $matches);
     $this->assertEquals(0, $badLineEndCount);
     $badLineEndCount = preg_match_all("/\\x0d/", $smtpLog, $matches);
     $this->assertTrue(preg_match_all("/\\x0d/", $smtpLog, $matches) > 70, 'unix line ends are missing');
 }
 /**
  * test line end encoding of Zend_Mime_Part / Smtp Protocol
  */
 public function testSendWithWrongLineEnd()
 {
     $this->markTestSkipped('FIXME: 0011688: fix line end encoding in attachments');
     // build message with wrong line end rfc822 part
     $mail = new Tinebase_Mail('utf-8');
     $mail->setBodyText('testmail' . "\r\n" . "\r\n");
     $mail->setFrom($this->_getEmailAddress(), 'unittest');
     $mail->setSubject('line end test');
     $mail->addTo($this->_getEmailAddress());
     $mail->addHeader('X-Tine20TestMessage', 'lineend');
     // replace EOLs
     $content = file_get_contents(dirname(dirname(__FILE__)) . '/files/text_plain.eml');
     $content = preg_replace("/\\x0a/", "\r\n", $content);
     $stream = fopen("php://temp", 'r+');
     fputs($stream, $content);
     rewind($stream);
     $attachment = new Zend_Mime_Part($stream);
     $attachment->type = Felamimail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822;
     $attachment->encoding = null;
     $attachment->charset = 'ISO-8859-1';
     $attachment->filename = 'attach.eml';
     $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
     $mail->addAttachment($attachment);
     $smtpConfig = $this->_account->getSmtpConfig();
     $transport = new Felamimail_Transport($smtpConfig['hostname'], $smtpConfig);
     Zend_Mail_Protocol_Abstract::$loggingEnabled = true;
     $mail->send($transport);
     Zend_Mail_Protocol_Abstract::$loggingEnabled = false;
     $smtpLog = $transport->getConnection()->getLog();
     $badLineEndCount = preg_match_all("/\\x0d\\x0d\\x0a/", $smtpLog, $matches);
     $this->assertEquals(0, $badLineEndCount);
     $unixLineEndCount = preg_match_all("/\\x0d/", $smtpLog, $matches);
     $this->assertTrue($unixLineEndCount > 70, 'unix line ends are missing (got ' . $unixLineEndCount . ' unix line ends)');
 }