0011556: sending mails to multiple recipients fails
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 19 Jan 2016 09:12:34 +0000 (10:12 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 20 Jan 2016 11:50:37 +0000 (12:50 +0100)
* adds another trim() to remove leading/trailing spaces

https://forge.tine20.org/view.php?id=11556

Change-Id: I826b88c5655b651a11983d1e82724cc587bd346c
Reviewed-on: http://gerrit.tine20.com/customers/2595
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Felamimail/Frontend/ActiveSyncTest.php
tests/tine20/Tinebase/AllTests.php
tests/tine20/Tinebase/MailTest.php [new file with mode: 0644]
tine20/Tinebase/Mail.php

index 772042c..f9adde5 100644 (file)
@@ -348,7 +348,7 @@ class Felamimail_Frontend_ActiveSyncTest extends TestCase
     }
     
     /**
-     * Test wether Base64Decoded Messages can be send or not
+     * Test whether Base64Decoded Messages can be send or not
      * 
      * @see 0008572: email reply text garbled
      */
@@ -380,7 +380,39 @@ dGVzdAo=&#13;
         
         $this->_sendMailTestHelper($email, $messageId, $stringToCheck, "Syncroton_Command_SendMail");
     }
-    
+
+    /**
+     * @see 0011556: sending mails to multiple recipients fails
+     */
+    public function testSendMessageToMultipleRecipients ()
+    {
+        $controller = $this->_getController($this->_getDevice(Syncroton_Model_Device::TYPE_ANDROID_40));
+
+        $messageId = '<j5wxaho1t8ggvk5cef7kqc6i.1373048280847@email.android.com>';
+
+        $email = '<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+<SendMail xmlns="uri:ComposeMail">
+  <ClientId>SendMail-158383807994574</ClientId>
+  <SaveInSentItems/>
+  <Mime>Date: Fri, 05 Jul 2013 20:18:00 +0200&#13;
+Subject: Fgh&#13;
+Message-ID: ' . htmlspecialchars($messageId) . '&#13;
+From: l.kneschke@metaways.de&#13;
+To: ' . $this->_emailTestClass->getEmailAddress() . ', ' . $this->_emailTestClass->getEmailAddress() . '&gt;&#13;
+MIME-Version: 1.0&#13;
+Content-Type: text/plain; charset=utf-8&#13;
+Content-Transfer-Encoding: base64&#13;
+&#13;
+dGVzdAo=&#13;
+</Mime>
+</SendMail>';
+
+        $stringToCheck = 'test';
+
+        $this->_sendMailTestHelper($email, $messageId, $stringToCheck, "Syncroton_Command_SendMail");
+    }
+
     /**
      * testCalendarInvitation (should not be sent)
      * 
index c1f0f3a..7231529 100644 (file)
@@ -61,6 +61,7 @@ class Tinebase_AllTests
         $suite->addTestSuite('Tinebase_FileSystem_RecordAttachmentsTest');
         $suite->addTestSuite('Tinebase_FileSystemTest');
         $suite->addTestSuite('Tinebase_ControllerTest');
+        $suite->addTestSuite('Tinebase_MailTest');
         $suite->addTestSuite('Tinebase_NotificationTest');
         $suite->addTestSuite('Tinebase_Model_Filter_TextTest');
         $suite->addTestSuite('Tinebase_TagsTest');
diff --git a/tests/tine20/Tinebase/MailTest.php b/tests/tine20/Tinebase/MailTest.php
new file mode 100644 (file)
index 0000000..c0891e1
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Tine 2.0 - http://www.tine20.org
+ * 
+ * @package     Tinebase
+ * @license     http://www.gnu.org/licenses/agpl.html
+ * @copyright   Copyright (c) 2016 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author      Philipp Schüle <p.schuele@metaways.de>
+ * 
+ */
+
+/**
+ * Test class for Tinebase_MailTest
+ */
+class Tinebase_MailTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @see 0011556: sending mails to multiple recipients fails
+     */
+    public function testParseAdresslist()
+    {
+        $addressesString = 'abc@example.org, abc2@example.org';
+        $addresses = Tinebase_Mail::parseAdresslist($addressesString);
+        
+        $this->assertEquals(array(
+            array('name' => null, 'address' => 'abc@example.org'),
+            array('name' => null, 'address' => 'abc2@example.org')
+        ), $addresses, print_r($addresses, true));
+    }
+}
index 3084a22..f5dd02d 100644 (file)
@@ -527,7 +527,7 @@ class Tinebase_Mail extends Zend_Mail
                 $addresses[$key] = array('name' => substr($name, 0, 250), 'address' => $address);
             } else {
                 $address = preg_replace('/[,;]*/i', '', $address);
-                $addresses[$key] = array('name' => null, 'address' => $address);
+                $addresses[$key] = array('name' => null, 'address' => trim($address));
             }
         }