Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_mail
Commits
d707f363
Commit
d707f363
authored
5 years ago
by
Georgi Mateev
Browse files
Options
Downloads
Patches
Plain Diff
[BUGFIX] 1584 fix contact form placeholders
parent
97217bb3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!23
[BUGFIX] 1584 fix contact form placeholders
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Controller/NewsletterController.php
+3
-2
3 additions, 2 deletions
Classes/Controller/NewsletterController.php
Classes/Service/MailTemplateService.php
+53
-17
53 additions, 17 deletions
Classes/Service/MailTemplateService.php
with
56 additions
and
19 deletions
Classes/Controller/NewsletterController.php
+
3
−
2
View file @
d707f363
...
...
@@ -376,6 +376,7 @@ class NewsletterController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
public
function
sendTestMailAction
(
array
$parameters
=
[])
{
$arguments
=
[];
...
...
@@ -458,7 +459,7 @@ class NewsletterController extends ActionController {
'www'
=>
' www.example.com'
,
]
]);
$mailIsSend
=
$mailTemplateService
->
sendEmail
(
TRUE
);
$mailIsSend
=
$mailTemplateService
->
sendEmail
(
TRUE
,
TRUE
);
}
}
else
{
...
...
@@ -489,7 +490,7 @@ class NewsletterController extends ActionController {
$mailTemplateService
->
setMarkers
([
'user'
=>
$recipient
]);
// no real error handling here, one must check the MailQueue
$mailTemplateService
->
sendEmail
(
FALSE
);
$mailTemplateService
->
sendEmail
(
FALSE
,
TRUE
);
}
catch
(
\Exception
$e
)
{
// Invalid email address could not be loaded to queue
$errorRecipients
[]
=
$recipient
[
'uid'
]
.
' - '
...
...
This diff is collapsed.
Click to expand it.
Classes/Service/MailTemplateService.php
+
53
−
17
View file @
d707f363
...
...
@@ -936,9 +936,11 @@ class MailTemplateService {
* @param RegisterService $registerService
* @param string $defaultTemplateContent
* @param int $siteRootId
* @param boolean $isNewsletter
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
protected
function
extractValuesForMail
(
$template
,
RegisterService
$registerService
,
$defaultTemplateContent
,
$siteRootId
):
void
{
protected
function
extractValuesForMail
(
$template
,
RegisterService
$registerService
,
$defaultTemplateContent
,
$siteRootId
,
$isNewsletter
):
void
{
/** @var StandaloneView $emailView */
$emailView
=
$this
->
objectManager
->
get
(
StandaloneView
::
class
);
$emailView
->
assignMultiple
(
$this
->
markers
);
...
...
@@ -981,35 +983,54 @@ class MailTemplateService {
//TODO: is this object even in use somewhere?
$this
->
mailMessage
->
setSubject
(
$subject
);
if
(
$this
->
fromAddress
===
$this
->
defaultFromAddress
)
{
$fromMail
=
''
;
if
(
!
$isNewsletter
&&
$template
!==
NULL
)
{
// if it's a non-newsletter email with a template:
// get the values explicitly from the template and parse the markers
$fromMail
=
$this
->
parseMarkers
(
$template
->
getFromMail
(),
$emailView
);
}
elseif
(
$this
->
fromAddress
===
$this
->
defaultFromAddress
)
{
// in other cases (newsletter or no template) - check for overwritten values
$fromMail
=
$this
->
parseMarkers
(
empty
(
$this
->
overwrittenFromMail
)
&&
$template
?
$template
->
getFromMail
()
:
$this
->
overwrittenFromMail
,
$emailView
);
if
(
$fromMail
)
{
// we don't want to override the default in that case
$this
->
setFromAddress
(
$fromMail
);
}
}
if
(
$fromMail
)
{
// we don't want to override the default in that case
$this
->
setFromAddress
(
$fromMail
);
}
if
(
$this
->
fromName
===
$this
->
defaultFromName
)
{
$fromName
=
''
;
if
(
!
$isNewsletter
&&
$template
!==
NULL
)
{
$fromName
=
$this
->
parseMarkers
(
$template
->
getFromName
(),
$emailView
);
}
else
if
(
$this
->
fromName
===
$this
->
defaultFromName
)
{
$fromName
=
$this
->
parseMarkers
(
(
empty
(
$this
->
overwrittenFromName
)
&&
$template
?
$template
->
getFromName
()
:
$this
->
overwrittenFromName
),
(
empty
(
$this
->
overwrittenFromName
)
&&
$template
?
$template
->
getFromName
(
)
:
$this
->
overwrittenFromName
),
$emailView
);
if
(
$fromName
)
{
// we don't want to override the default if this value is empty here
$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
===
''
)
{
if
(
!
$isNewsletter
&&
$template
!==
NULL
)
{
$replyTo
=
$this
->
parseMarkers
(
$template
->
getReplyTo
(),
$emailView
);
$this
->
setReplyToAddress
(
$replyTo
);
}
else
if
(
$this
->
replyToAddress
===
''
)
{
$replyTo
=
$this
->
parseMarkers
(
(
empty
(
$this
->
overwrittenReplyTo
)
&&
$template
?
$template
->
getReplyTo
()
:
$this
->
overwrittenReplyTo
),
(
empty
(
$this
->
overwrittenReplyTo
)
&&
$template
?
$template
->
getReplyTo
(
)
:
$this
->
overwrittenReplyTo
),
$emailView
);
$this
->
setReplyToAddress
(
$replyTo
);
}
if
(
empty
(
$this
->
ccAddresses
))
{
if
(
!
$isNewsletter
&&
$template
!==
NULL
)
{
$cc
=
$this
->
parseMarkers
(
$template
->
getCc
(),
$emailView
);
if
(
$cc
)
{
$this
->
setCcAddresses
(
$cc
);
}
}
else
if
(
empty
(
$this
->
ccAddresses
))
{
$cc
=
$this
->
parseMarkers
(
(
empty
(
$this
->
overwrittenCc
)
&&
$template
?
$template
->
getCc
()
:
$this
->
overwrittenCc
),
$emailView
...
...
@@ -1017,7 +1038,12 @@ class MailTemplateService {
$this
->
setCcAddresses
(
$cc
);
}
if
(
empty
(
$this
->
bccAddresses
))
{
if
(
!
$isNewsletter
&&
$template
!==
NULL
)
{
$bcc
=
$this
->
parseMarkers
(
$template
->
getBcc
(),
$emailView
);
if
(
$bcc
)
{
$this
->
setBccAddresses
(
$bcc
);
}
}
else
if
(
empty
(
$this
->
bccAddresses
))
{
$bcc
=
$this
->
parseMarkers
(
(
empty
(
$this
->
overwrittenBcc
)
&&
$template
?
$template
->
getBcc
()
:
$this
->
overwrittenBcc
),
$emailView
...
...
@@ -1025,7 +1051,12 @@ class MailTemplateService {
$this
->
setBccAddresses
(
$bcc
);
}
if
(
$this
->
toAddresses
===
''
)
{
if
(
!
$isNewsletter
&&
$template
!==
NULL
)
{
$toAddress
=
$this
->
parseMarkers
(
$template
->
getToAddress
(),
$emailView
);
if
(
$toAddress
)
{
$this
->
setToAddresses
(
$toAddress
);
}
}
else
if
(
$this
->
toAddresses
===
''
)
{
$toAddress
=
$this
->
parseMarkers
(
(
empty
(
$this
->
overwrittenToAddresses
)
&&
$template
?
$template
->
getToAddress
()
:
$this
->
overwrittenToAddresses
),
$emailView
...
...
@@ -1068,7 +1099,7 @@ class MailTemplateService {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
*/
public
function
sendEmail
(
$isPreview
=
FALSE
):
bool
{
public
function
sendEmail
(
$isPreview
=
FALSE
,
$isNewsletter
=
FALSE
):
bool
{
if
(
$isPreview
)
{
//TODO: remove this from here
$this
->
setIgnoreMailQueue
(
TRUE
);
}
...
...
@@ -1094,7 +1125,12 @@ class MailTemplateService {
$this
->
setToAddresses
(
\trim
(
$template
->
getToAddress
()));
}
$this
->
extractValuesForMail
(
$template
,
$registerService
,
$defaultTemplateContent
,
$siteRootId
);
$this
->
extractValuesForMail
(
$template
,
$registerService
,
$defaultTemplateContent
,
$siteRootId
,
$isNewsletter
);
// Fallback empty recipient address to the default sender address
if
(
!
$this
->
mailMessage
->
getTo
())
{
$this
->
mailMessage
->
setTo
(
$this
->
defaultFromAddress
);
}
$mail
=
$this
->
addMailToMailQueue
(
$this
->
extensionKey
,
$this
->
templateName
,
$this
->
getSubjectToSend
(),
$this
->
getMailBodyToSend
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment