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
a2b5fb6b
Commit
a2b5fb6b
authored
8 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Refactoring Test Mail & Controller for DB implementation. Fixed some bugs
parent
51822813
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Classes/Controller/MailController.php
+2
-0
2 additions, 0 deletions
Classes/Controller/MailController.php
Classes/Service/MailTemplateService.php
+37
-9
37 additions, 9 deletions
Classes/Service/MailTemplateService.php
Configuration/TypoScript/setup.ts
+1
-1
1 addition, 1 deletion
Configuration/TypoScript/setup.ts
with
40 additions
and
10 deletions
Classes/Controller/MailController.php
+
2
−
0
View file @
a2b5fb6b
...
...
@@ -98,6 +98,8 @@ class MailController extends ActionController {
);
}
$this
->
view
->
assign
(
'selectedLanguageLeft'
,
$this
->
settings
[
'templateDefaultLanguage'
]);
$this
->
view
->
assign
(
'selectedLanguageRight'
,
$this
->
settings
[
'templateDefaultLanguage'
]);
$this
->
view
->
assign
(
'selectedTemplateKey'
,
$secondLevelFirstEntry
);
$this
->
view
->
assign
(
'selectedExtensionKey'
,
$firstEntry
);
}
...
...
This diff is collapsed.
Click to expand it.
Classes/Service/MailTemplateService.php
+
37
−
9
View file @
a2b5fb6b
...
...
@@ -3,7 +3,9 @@
namespace
SGalinski\SgMail\Service
;
use
SGalinski\SgMail\Domain\Model\Mail
;
use
SGalinski\SgMail\Domain\Model\Template
;
use
SGalinski\SgMail\Domain\Repository\MailRepository
;
use
TYPO3\CMS\Core\Exception
;
use
TYPO3\CMS\Core\Mail\MailMessage
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Object\ObjectManager
;
...
...
@@ -110,6 +112,12 @@ class MailTemplateService {
*/
private
$bccAddresses
=
[];
/**
* @var \SGalinski\SgMail\Domain\Repository\TemplateRepository
* @inject
*/
protected
$templateRepository
=
NULL
;
/**
* MailTemplateService constructor.
*/
...
...
@@ -125,9 +133,27 @@ class MailTemplateService {
$this
->
mailMessage
->
setFrom
(
$this
->
fromAddress
);
$this
->
bccAddresses
=
GeneralUtility
::
trimExplode
(
','
,
$this
->
tsSettings
[
'mail'
][
'default'
][
'bcc'
]);
$this
->
bccAddresses
=
GeneralUtility
::
trimExplode
(
','
,
$this
->
tsSettings
[
'mail'
][
'default'
][
'cc'
]);
$this
->
mailMessage
->
setBcc
(
$this
->
bccAddresses
);
$this
->
mailMessage
->
setBcc
(
$this
->
ccAddresses
);
$this
->
ccAddresses
=
GeneralUtility
::
trimExplode
(
','
,
$this
->
tsSettings
[
'mail'
][
'default'
][
'cc'
]);
foreach
(
$this
->
bccAddresses
as
$index
=>
$email
)
{
if
(
!
filter_var
(
$email
,
FILTER_VALIDATE_EMAIL
))
{
unset
(
$this
->
bccAddresses
[
$index
]);
}
}
foreach
(
$this
->
ccAddresses
as
$index
=>
$email
)
{
if
(
!
filter_var
(
$email
,
FILTER_VALIDATE_EMAIL
))
{
unset
(
$this
->
ccAddresses
[
$index
]);
}
}
if
(
sizeof
(
$this
->
bccAddresses
)
>
0
)
{
$this
->
mailMessage
->
setBcc
(
$this
->
bccAddresses
);
}
if
(
sizeof
(
$this
->
ccAddresses
)
>
0
)
{
$this
->
mailMessage
->
setCc
(
$this
->
ccAddresses
);
}
}
/**
...
...
@@ -164,13 +190,16 @@ class MailTemplateService {
* Send the Email
*/
public
function
sendEmail
()
{
$templateEntry
=
self
::
$registerArray
[
$this
->
extensionKey
][
$this
->
templateName
];
$objectManager
=
GeneralUtility
::
makeInstance
(
ObjectManager
::
class
);
/** @var StandaloneView $emailView */
$emailView
=
$objectManager
->
get
(
StandaloneView
::
class
);
$emailView
->
setTemplatePathAndFilename
(
$templateEntry
[
'templatePath'
]
.
$this
->
language
.
'.sg_mail.locallang.html'
);
/** @var Template $template */
$template
=
$this
->
templateRepository
->
findTemplate
(
$this
->
extensionKey
,
$this
->
templateName
,
$this
->
language
)
->
getFirst
();
$emailView
->
setTemplateSource
(
$template
->
getContent
());
$emailView
->
assignMultiple
(
$this
->
markers
);
$emailBody
=
$emailView
->
render
();
...
...
@@ -179,7 +208,7 @@ class MailTemplateService {
$emailBody
=
nl2br
(
$emailBody
);
$emailBody
=
preg_replace
(
'/(<br[\s]?[\/]?>[\s]*){3,}/'
,
'<br /><br />'
,
$emailBody
);
$this
->
mailMessage
->
setSubject
(
$t
his
->
s
ubject
);
$this
->
mailMessage
->
setSubject
(
$t
emplate
->
getS
ubject
()
);
$this
->
mailMessage
->
setBody
(
$emailBody
,
'text/html'
);
$this
->
mailMessage
->
send
();
}
else
{
...
...
@@ -327,5 +356,4 @@ class MailTemplateService {
return
$this
;
}
}
This diff is collapsed.
Click to expand it.
Configuration/TypoScript/setup.ts
+
1
−
1
View file @
a2b5fb6b
...
...
@@ -10,7 +10,7 @@ module.tx_sgmail {
test
.
from
=
info
@
test
.
de
test
.
subject
=
This
is
just
a
Test
E
-
Mail
default
.
from
=
default
.
from
=
torsten
@
sgalinski
.
de
default
.
bcc
=
default
.
cc
=
}
...
...
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