Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
sg_mail
Commits
02a5bd3e
Commit
02a5bd3e
authored
Feb 26, 2020
by
Georgi Mateev
Browse files
[BUGFIX] 1650 fix fromName and fromAddress overwriting
parent
094d4c29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Classes/Service/MailTemplateService.php
View file @
02a5bd3e
...
...
@@ -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
===
''
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment