78 $this->setHtmlContent();
79 $this->setPlainContent();
82 return $this->render();
93 if (isset($this->typoScript[
'subject'])) {
94 $subject = $this->typoScript[
'subject'];
95 } elseif ($this->requestHandler->has($this->typoScript[
'subjectField'])) {
96 $subject = $this->requestHandler->get($this->typoScript[
'subjectField']);
101 $this->mailMessage->setSubject($subject);
113 if ($this->typoScript[
'senderEmail']) {
114 $fromEmail = $this->typoScript[
'senderEmail'];
115 } elseif ($this->requestHandler->has($this->typoScript[
'senderEmailField'])) {
116 $fromEmail = $this->requestHandler->get($this->typoScript[
'senderEmailField']);
118 $fromEmail =
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromAddress'];
120 if (!\
TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($fromEmail)) {
124 if ($this->typoScript[
'senderName']) {
125 $fromName = $this->typoScript[
'senderName'];
126 } elseif ($this->requestHandler->has($this->typoScript[
'senderNameField'])) {
127 $fromName = $this->requestHandler->get($this->typoScript[
'senderNameField']);
129 $fromName =
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromName'];
132 if (!empty($fromName)) {
133 $from = array($fromEmail => $fromName);
137 $this->mailMessage->setFrom($from);
146 protected function filterValidEmails($emails) {
147 if (!is_string($emails)) {
154 $addresses = $addressParser->parseAddressList();
156 $validEmails = array();
157 foreach ($addresses as $address) {
158 $fullAddress = $address->mailbox .
'@' . $address->host;
159 if (\
TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($fullAddress)) {
160 if ($address->personal) {
161 $validEmails[$fullAddress] = $address->personal;
163 $validEmails[] = $fullAddress;
178 $validEmails = $this->filterValidEmails($this->typoScript[
'recipientEmail']);
179 if (count($validEmails)) {
180 $this->mailMessage->setTo($validEmails);
192 $validEmails = $this->filterValidEmails($this->typoScript[
'ccEmail']);
193 if (count($validEmails)) {
194 $this->mailMessage->setCc($validEmails);
206 if (isset($this->typoScript[
'replyToEmail'])) {
207 $emails = $this->typoScript[
'replyToEmail'];
208 } elseif ($this->requestHandler->has($this->typoScript[
'replyToEmailField'])) {
209 $emails = $this->requestHandler->get($this->typoScript[
'replyToEmailField']);
211 $validEmails = $this->filterValidEmails($emails);
212 if (!empty($validEmails)) {
213 $this->mailMessage->setReplyTo($validEmails);
227 if ($this->typoScript[
'priority']) {
230 $this->mailMessage->setPriority($priority);
241 if ($this->typoScript[
'organization']) {
242 $organization = $this->typoScript[
'organization'];
244 $this->mailMessage->getHeaders()->addTextHeader(
'Organization', $organization);
257 $characterSet = NULL;
258 if (
$GLOBALS[
'TSFE']->config[
'config'][
'formMailCharset']) {
259 $characterSet =
$GLOBALS[
'TSFE']->csConvObj->parse_charset(
$GLOBALS[
'TSFE']->config[
'config'][
'formMailCharset']);
260 } elseif (
$GLOBALS[
'TSFE']->metaCharset !=
$GLOBALS[
'TSFE']->renderCharset) {
261 $characterSet =
$GLOBALS[
'TSFE']->metaCharset;
264 $this->mailMessage->setCharset($characterSet);
275 protected function setHtmlContent() {
278 $htmlContent = $view->get();
279 $this->mailMessage->setBody($htmlContent,
'text/html');
289 protected function setPlainContent() {
292 $plainContent = $view->render();
293 $this->mailMessage->addPart($plainContent,
'text/plain');
303 if ($this->mailMessage->getTo() && $this->mailMessage->getBody()) {
304 $this->mailMessage->send();
313 protected function render() {
316 return $view->render();
326 $pattern =
'/[\\r\\n\\f\\e]/';
327 if (preg_match($pattern, $string) > 0) {
328 $this->dirtyHeaders[] = $string;
340 $formElements = $this->form->getElements();
341 $values = $this->requestHandler->getByMethod();
342 $this->addAttachmentsFromElements($formElements, $values);
353 protected function addAttachmentsFromElements($elements, $submittedValues) {
355 foreach ($elements as $element) {
356 if (is_a($element,
'TYPO3\\CMS\\Form\\Domain\\Model\\Element\\ContainerElement')) {
357 $this->addAttachmentsFromElements($element->getElements(), $submittedValues);
360 if (is_a($element,
'TYPO3\\CMS\\Form\\Domain\\Model\\Element\\FileuploadElement')) {
361 $elementName = $element->getName();
362 if (is_array($submittedValues[$elementName]) && isset($submittedValues[$elementName][
'tempFilename'])) {
363 $filename = $submittedValues[$elementName][
'tempFilename'];
364 if (is_file($filename) && \
TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath($filename)) {
365 $this->mailMessage->attach(\Swift_Attachment::fromPath($filename)->setFilename($submittedValues[$elementName][
'originalFilename']));
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
static getIndpEnv($getEnvName)
static makeInstance($className)
static getSystemFromAddress()
__construct(\TYPO3\CMS\Form\Domain\Model\Form $form, array $typoScript)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
sanitizeHeaderString($string)