Skip to content

Commit

Permalink
support the Symfony email via \JambageCom\Div2007\Utility\MailUtility…
Browse files Browse the repository at this point in the history
…::send
  • Loading branch information
franzholz committed Feb 18, 2021
1 parent 8d0be8a commit f843924
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
1 change: 0 additions & 1 deletion lib/class.tx_ttproducts_billdelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public function writeFile ($filename, $content) {


public function generateBill (&$errorCode, $templateCode, $mainMarkerArray, $basketExtra, $type, $generationConf) {

$basketView = GeneralUtility::makeInstance('tx_ttproducts_basket_view');
$basketObj = GeneralUtility::makeInstance('tx_ttproducts_basket');
$infoViewObj = GeneralUtility::makeInstance('tx_ttproducts_info_view');
Expand Down
80 changes: 48 additions & 32 deletions lib/class.tx_ttproducts_email_div.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ static public function send_mail (
$bcc = '',
$returnPath = ''
) {
global $TYPO3_CONF_VARS;

if ($toEMail == '' || $fromEMail == '' || ($html == '' && $message == '')) {

return false;
Expand All @@ -78,39 +76,57 @@ static public function send_mail (

$fromName = str_replace('"', '\'', $fromName);

$mailMessage = tx_div2007_core::newMailMessage();
$mailMessage->setCharset('UTF-8')
->setTo($toEMail)
->setFrom(array($fromEMail => $fromName))
->setReturnPath($returnPath)
->setSubject($subject)
->setBody($html, 'text/html')
->addPart($message, 'text/plain');

$type = $mailMessage->getHeaders()->get('Content-Type');
$type->setParameter('charset', 'UTF-8');

if (isset($attachment)) {
if (is_array($attachment)) {
$attachmentArray = $attachment;
} else {
$attachmentArray = array($attachment);
}
foreach ($attachmentArray as $theAttachment) {
if (file_exists($theAttachment)) {
$mailMessage->attach(Swift_Attachment::fromPath($theAttachment));
if (version_compare(TYPO3_version, '10.0.0', '<')) {
$mailMessage = tx_div2007_core::newMailMessage();
$mailMessage->setCharset('UTF-8')
->setTo($toEMail)
->setFrom(array($fromEMail => $fromName))
->setReturnPath($returnPath)
->setSubject($subject)
->setBody($html, 'text/html')
->addPart($message, 'text/plain');

$type = $mailMessage->getHeaders()->get('Content-Type');
$type->setParameter('charset', 'UTF-8');

if (isset($attachment)) {
if (is_array($attachment)) {
$attachmentArray = $attachment;
} else {
$attachmentArray = array($attachment);
}
foreach ($attachmentArray as $theAttachment) {
if (file_exists($theAttachment)) {
$mailMessage->attach(Swift_Attachment::fromPath($theAttachment));
}
}
}
if ($bcc != '') {
$mailMessage->addBcc($bcc);
}
$mailMessage->send();
$result = $mailMessage->isSent();
if ($conf['errorLog'] && count($mailMessage->getFailedRecipients())) {
error_log('send_mail Pos 2 undelivered emails: ' . implode(',', $mailMessage->getFailedRecipients()) . chr(13), 3, $conf['errorLog']);
}
} else {
$result = \JambageCom\Div2007\Utility\MailUtility::send(
implode($toEMail, ','),
$subject,
$message,
$html,
$fromEMail,
$fromName,
'',
'',
'',
$fromEMail,
'',
TT_PRODUCTS_EXT,
'sendMail'
);
}

if ($bcc != '') {
$mailMessage->addBcc($bcc);
}
$mailMessage->send();
$result = $mailMessage->isSent();
if ($conf['errorLog'] && count($mailMessage->getFailedRecipients())) {
error_log('send_mail Pos 2 undelivered emails: ' . implode(',', $mailMessage->getFailedRecipients()) . chr(13), 3, $conf['errorLog']);
}
return $result;
}

Expand Down Expand Up @@ -181,7 +197,7 @@ static public function sendNotifyEmail (
$parts = explode(chr(10),$emailContent,2);
$subject = trim($parts[0]);
$plain_message = trim($parts[1]);
self::send_mail(implode($recipients,','), $subject, $plain_message, $tmp='', $senderemail, $sendername);
self::send_mail(implode($recipients,','), $subject, $plain_message, $tmp='', $senderemail, $sendername);
}
}
}
Expand Down

0 comments on commit f843924

Please sign in to comment.