[TASK] Migration from htmlmail to swiftmailer 58/25658/2
authorNicole Cordes <cordes@cps-it.de>
Sat, 23 Nov 2013 05:47:53 +0000 (06:47 +0100)
committerNicole Cordes <typo3@cordes.co>
Sat, 23 Nov 2013 05:56:47 +0000 (06:56 +0100)
Resolves: #49544
Change-Id: I5aa1a9fe7a70f4b3f7a34db8800dc9a1a9a9b932
Reviewed-on: https://review.typo3.org/25658
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
pi1/class.tx_tipafriendplus_pi1.php

index fc1b244..efd1db8 100644 (file)
@@ -398,39 +398,33 @@ class tx_tipafriendplus_pi1 extends tslib_pibase {
                // Substitute in template
                $content = $this->cObj->substituteMarkerArrayCached($subpart, $markerArray);
 
-               // Set subject, conten and headers
-               $headers = array();
-               $headers[] = 'FROM: ' . $tipData['name'] . ' <' . $tipData['email'] . '>';
-
                // If htmlmail lib is included, then generate a nice HTML-email
                if ($this->conf['htmlmail'] || $tipData['html_message']) {
-                       $Typo3_htmlmail = t3lib_div::makeInstance('t3lib_htmlmail');
-                       list($subject, $plain_message) = explode(chr(10), trim($content), 2);
-                       $Typo3_htmlmail->start();
-                       $Typo3_htmlmail->useBase64();
-
-                       $Typo3_htmlmail->subject = $subject;
-                       $Typo3_htmlmail->from_email = $tipData['email'];
-                       $Typo3_htmlmail->from_name = $tipData['name'];
-                       $Typo3_htmlmail->replyto_email = $tipData['email'];
-                       $Typo3_htmlmail->replyto_name = $tipData['name'];
-                       $Typo3_htmlmail->organisation = '';
-                       $Typo3_htmlmail->priority = 3;
-
-                       // This will fail if the url is password protected!
-                       $Typo3_htmlmail->addHTML($url);
-                       $Typo3_htmlmail->addPlain($plain_message);
-
-                       $Typo3_htmlmail->setHeaders();
-                       $Typo3_htmlmail->setContent();
-                       $Typo3_htmlmail->setRecipient($tipData['recipient']);
-
-                       //                      debug($Typo3_htmlmail->theParts);
-                       $Typo3_htmlmail->sendtheMail();
+                       list($subject, $plainMessage) = array_map('trim', explode(chr(10), trim($content), 2));
+                       $searchArray = array(
+                               $tipData['email'],
+                               $url
+                       );
+                       $replaceArray = array(
+                               '<a href="mailto:' . $tipData['email'] . '">' . $tipData['email'] . '</a>',
+                               '<a href="' . $url . '">' . $url . '</a>'
+                       );
+                       $htmlMessage = nl2br(str_replace($searchArray, $replaceArray, $plainMessage));
+                       $htmlMail = t3lib_div::makeInstance('t3lib_mail_Message');
+                       $htmlMail->setTo($tipData['recipient'])
+                               ->setFrom($tipData['email'], $tipData['name'])
+                               ->setReplyTo($tipData['email'], $tipData['name'])
+                               ->setReturnPath($tipData['email'])
+                               ->setPriority(3)
+                               ->setSubject($subject)
+                               ->addPart($htmlMessage, 'text/html')
+                               ->addPart($plainMessage, 'text/plain')
+                               ->send();
+
                } else { // Plain mail:
                        // Sending mail:
-                       $plain_message = trim($content);
-                       $this->cObj->sendNotifyEmail($plain_message, $tipData['recipient'], '', $tipData['email'], $tipData['name']);
+                       $plainMessage = trim($content);
+                       $this->cObj->sendNotifyEmail($plainMessage, $tipData['recipient'], '', $tipData['email'], $tipData['name']);
                }
        }