Project

General

Profile

Actions

Bug #71752

closed

Attach the message with a "cid" $cid = $mail->embed(\Swift_Image::fromPath('<path/to/image.png>')); not working

Added by Martin Weymayer about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-11-21
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

if i try to embed cid image in email an error occures (typo3 7.5 and 7.6):
//Attach the message with a "cid"
$cid = $mail->embed(\Swift_Image::fromPath('<path/to/image.png>'));

Fatal error: Call to undefined method TYPO3\CMS\Fluid\View\StandaloneView::embed() in /home/xxx/public_html/xxx/typo3conf/ext/xxx/Classes/Controller/XxxxController.php on line 123

normal email senden works perfectly.

martin

Actions #1

Updated by Wouter Wolters about 9 years ago

  • Status changed from New to Needs Feedback

Can you post some more of your actual code?

It looks like you are doing it wrong, $mail is an instance of StandAloneView...

Actions #2

Updated by Martin Weymayer about 9 years ago

/** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView */
$email = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$email->setTemplatePathAndFilename('typo3conf/ext/xxx/Resources/Private/Templates/xxx/xxx.html');
$email->assign('args', $args['newxx']);

// Attach the message with a "cid"
$cid = $email->embed(\Swift_Image::fromPath('fileadmin/templates/xx/images/xxx_xxx.jpg'));
$email->assign('cid', $cid);

$emailBody = $email->render();

/** @var $message \TYPO3\CMS\Core\Mail\MailMessage */
$message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$message->setTo($sender)
>setFrom($recipient)
>setSubject($subject);

// Possible attachments here
//foreach ($attachments as $attachment) {
// $message->attach($attachment);
//}

// Plain text example
$message->setBody($emailBody, 'text/plain');

// HTML Email
$message->setBody($emailBody, 'text/html');

$message->send();

Actions #3

Updated by Wouter Wolters about 9 years ago

  • Status changed from Needs Feedback to Closed

This is obviously wrong code you are using. StandAloneView does not have a embed function. This function is only available in \TYPO3\CMS\Core\Mail\MailMessage.

What you can do is make a marker ###IMAGE### and replace that after you rendered your content with the CID you have fron the embed function.

If you have further questions feel free to join our Slack channel for support.
https://forger.typo3.org/slack

Actions

Also available in: Atom PDF