Inconsistence in config processing when sending emails with attachments
Bug Report
Current Behavior After configuring from/to emails and enabling sending of mails with attached PDF files, buyer started to receive mails with attached generated PDFs, however the seller did not - only a plain mail
Expected behavior/output Both seller and buyer should receive attached PDFs, if enabled
Environment
- TYPO3 version(s): 8.7.27
- cart version: 5.5.0
- Is your TYPO3 installation set up with Composer (Composer Mode): yes
- OS: OSX 10.14.4
Possible Solution in
web/typo3conf/ext/cart/Classes/Service/MailHandler.php
replace
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['getMailAttachmentsHook']) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['getMailAttachmentsHook'] as $_classRef) {
$_procObj = &GeneralUtility::makeInstance($_classRef);
$mail = $_procObj->getMailAttachments($mail, $orderItem, $to);
}
}
in sendSellerEmail function with this block from sendBuyerEmail:
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['MailAttachmentsHook']) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['MailAttachmentsHook'] as $className) {
$_procObj = GeneralUtility::makeInstance($className);
if (!$_procObj instanceof MailAttachmentHookInterface) {
throw new \UnexpectedValueException($className . ' must implement interface ' . MailAttachmentHookInterface::class, 123);
}
$mail = $_procObj->getMailAttachments($mail, $orderItem, $to);
}
}
Additional context I'm not 100% sure if the fix is valid, but I haven't found getMailAttachmentsHook anywhere else than on those 2 lines, in opposition to MailAttachmentsHook only. And it fixes the whole problem.
The hook is now replaced by an AttachmentEvent (see https://github.com/extcode/cart/pull/469/commits/f6cd388c9aa99478586700c1cfa814446b8ad980) so I will close this ticket as it seems quite outdated. You're welcome to respond if you think it still relevant.