Skip to content
Snippets Groups Projects
Commit 02a5bd3e authored by Georgi Mateev's avatar Georgi Mateev
Browse files

[BUGFIX] 1650 fix fromName and fromAddress overwriting

parent 094d4c29
No related branches found
No related tags found
No related merge requests found
......@@ -223,6 +223,16 @@ class MailTemplateService {
*/
private $subjectToSend;
/*
* @var string
*/
private $defaultFromAddress;
/**
* @var string
*/
private $defaultFromName;
/**
* @return string
*/
......@@ -335,18 +345,18 @@ class MailTemplateService {
// use defaultMailFromAddress if it is provided in LocalConfiguration.php; use the sg_mail TS setting as fallback
if (\filter_var($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'], FILTER_VALIDATE_EMAIL)) {
$this->fromAddress = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
$this->defaultFromAddress = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
} else if (!\filter_var($tsSettings['mail']['default']['from'], FILTER_VALIDATE_EMAIL)) {
$this->fromAddress = 'noreply@example.org';
$this->defaultFromAddress = 'noreply@example.org';
} else {
$this->fromAddress = $tsSettings['mail']['default']['from'];
if (!\filter_var($tsSettings['mail']['default']['from'], FILTER_VALIDATE_EMAIL)) {
$this->fromAddress = 'noreply@example.org';
} else {
$this->fromAddress = $tsSettings['mail']['default']['from'];
}
$this->defaultFromAddress = $tsSettings['mail']['default']['from'];
}
if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']) {
$this->fromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'];
$this->defaultFromName = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'];
}
$this->mailMessage->setFrom($this->fromAddress, $this->fromName);
......@@ -971,20 +981,24 @@ class MailTemplateService {
//TODO: is this object even in use somewhere?
$this->mailMessage->setSubject($subject);
if ($this->fromAddress === '') {
if ($this->fromAddress === $this->defaultFromAddress) {
$fromMail = $this->parseMarkers(
empty($this->overwrittenFromMail) && $template ? $template->getFromMail() : $this->overwrittenFromMail,
$emailView
);
$this->setFromAddress($fromMail);
if ($fromMail) { // we don't want to override the default in that case
$this->setFromAddress($fromMail);
}
}
if ($this->fromName === '') {
if ($this->fromName === $this->defaultFromName) {
$fromName = $this->parseMarkers(
(empty($this->overwrittenFromName) && $template ? $template->getFromName() : $this->overwrittenFromName),
$emailView
);
$this->setFromName($fromName);
if ($fromName) { // we don't want to override the default if this value is empty here
$this->setFromName($fromName);
}
}
if ($this->replyToAddress === '') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment