[TASK] Deprecate/rewrite old mail functions
authorJigal van Hemert <jigal@xs4all.nl>
Sun, 7 Apr 2013 21:31:24 +0000 (23:31 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 20 Apr 2013 22:28:08 +0000 (00:28 +0200)
Old mail functions must be either deprecated or rewritten to use the new
mail API that was introduced in 4.5. In Version the notifications for
workspace changes can use the new mail API too.

Change-Id: I42f73e278e06546ea87b506be296306f6541a936
Fixes: #47037
Related: #42321
Releases: 6.1
Reviewed-on: https://review.typo3.org/19739
Reviewed-by: Markus Klein
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/version/Classes/Hook/DataHandlerHook.php

index ad10d8d..338e5e8 100644 (file)
@@ -481,7 +481,6 @@ class DataHandlerHook {
                                }
                                // send an email to each individual user, to ensure the
                                // multilanguage version of the email
-                               $emailHeaders = $emailConfig['additionalHeaders'];
                                $emailRecipients = array();
                                // an array of language objects that are needed
                                // for emails with different languages
@@ -521,7 +520,18 @@ class DataHandlerHook {
                                        $emailSubject = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($emailSubject, $markers, '', TRUE, TRUE);
                                        $emailMessage = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($emailMessage, $markers, '', TRUE, TRUE);
                                        // Send an email to the recipient
-                                       \TYPO3\CMS\Core\Utility\GeneralUtility::plainMailEncoded($recipientData['email'], $emailSubject, $emailMessage, $emailHeaders);
+                                       /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
+                                       $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
+                                       if (!empty($recipientData['realName'])) {
+                                               $recipient = array($recipientData['email'] => $recipientData['realName']);
+                                       } else {
+                                               $recipient = $recipientData['email'];
+                                       }
+                                       $mail->setTo($recipient)
+                                               ->setSubject($emailSubject)
+                                               ->setFrom(\TYPO3\CMS\Core\Utility\MailUtility::getSystemFrom())
+                                               ->setBody($emailMessage);
+                                       $mail->send();
                                }
                                $emailRecipients = implode(',', $emailRecipients);
                                $tcemainObj->newlog2('Notification email for stage change was sent to "' . $emailRecipients . '"', $table, $id);