Fixed bug #17518: Content type "mailform" no longer accepts list of addresses for...
authorjigal <jigal@709f56b5-9817-0410-a4d7-c38de5d9e867>
Tue, 22 Feb 2011 18:46:19 +0000 (18:46 +0000)
committerjigal <jigal@709f56b5-9817-0410-a4d7-c38de5d9e867>
Tue, 22 Feb 2011 18:46:19 +0000 (18:46 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-5@10537 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_formmail.php
t3lib/mail/class.t3lib_mail_swiftmaileradapter.php

index 5fee51a..42fe4ad 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-22  Jigal van Hemert  <jigal@xs4all.nl>
+
+       * Fixed bug #17518: Content type "mailform" no longer accepts list of addresses for "Recipient List" (also fixed function description in t3lib_mail_SwiftMailerAdapter) 
+
 2011-02-22  Steffen Ritter  <info@steffen-ritter.net>
 
        * Fixed bug #16891: showpic.php causes a fatal error if parameters GET variable is not an array (Thanks to Helmut Hummel)
index 40448b3..5554ebb 100644 (file)
@@ -233,14 +233,14 @@ class t3lib_formmail {
                                $this->temporaryFiles[] = $theFile;
                        }
 
-                       $this->recipient = $valueList['recipient'];
+                       $this->recipient = $this->parseAddresses($valueList['recipient']);
                        $this->mailMessage->setSubject($this->subject)
                                        ->setFrom(array($this->fromAddress => $this->fromName))
                                        ->setTo($this->recipient)
                                        ->setPriority($this->priority);
                        $this->mailMessage->getHeaders()->addTextHeader('Organization', $this->organisation);
                        if ($valueList['recipient_copy']) {
-                               $this->mailMessage->addCc(trim($valueList['recipient_copy']));
+                               $this->mailMessage->addCc($this->parseAddresses($valueList['recipient_copy']));
                        }
                        if ($this->characterSet) {
                                $this->mailMessage->setCharset($this->characterSet);
@@ -274,6 +274,34 @@ class t3lib_formmail {
        }
        
        /**
+        * Parses mailbox headers and turns them into an array.
+        *
+        * Mailbox headers are a comma separated list of 'name <email@example.org' combinations or plain email addresses (or a mix
+        * of these).
+        * The resulting array has key-value pairs where the key is either a number (no display name in the mailbox header) and the
+        * value is the email address, or the key is the email address and the value is the display name.
+        *
+        * @param string $rawAddresses Comma separated list of email addresses (optionally with display name)
+        * @return array Parsed list of addresses.
+        */
+       protected function parseAddresses($rawAddresses = '') {
+                       /** @var $addressParser t3lib_mail_Rfc822AddressesParser */
+               $addressParser = t3lib_div::makeInstance('t3lib_mail_Rfc822AddressesParser', $rawAddresses);
+               $addresses = $addressParser->parseAddressList();
+               $addressList = array();
+               foreach ($addresses as $address) {
+                       if ($address->personal) {
+                               // item with name found ( name <email@example.org> )
+                               $addressList[$address->mailbox . '@' . $address->host] = $address->personal;
+                       } else {
+                               // item without name found ( email@example.org )
+                               $addressList[] = $address->mailbox . '@' . $address->host;
+                       }
+               }
+               return $addressList;
+       }
+
+       /**
         * Sends the actual mail and handles autorespond message
         *
         * @return boolean
index 025b466..64d7020 100644 (file)
@@ -290,8 +290,8 @@ class t3lib_mail_SwiftMailerAdapter implements t3lib_mail_MailerAdapter {
         *
         * Mailbox headers are a comma separated list of 'name <email@example.org' combinations or plain email addresses (or a mix
         * of these).
-        * The resulting array has key-value pairs where the key is either a number (no name in the mailbox header) or a display
-        * name and the value is the email address.
+        * The resulting array has key-value pairs where the key is either a number (no display name in the mailbox header) and the
+        * value is the email address, or the key is the email address and the value is the display name.
         *
         * @param string $rawAddresses Comma separated list of email addresses (optionally with display name)
         * @return array Parsed list of addresses.