Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
frontend-users
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QUIQQER
frontend-users
Commits
5a57f7b5
Commit
5a57f7b5
authored
Jun 11, 2019
by
Patrick Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: SendUserMails console tool -> send test mail before mass-sending emails
parent
be8194c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
+44
-4
src/QUI/FrontendUsers/Console/SendUserMails.php
src/QUI/FrontendUsers/Console/SendUserMails.php
+44
-4
No files found.
src/QUI/FrontendUsers/Console/SendUserMails.php
View file @
5a57f7b5
...
...
@@ -144,7 +144,34 @@ class SendUserMails extends QUI\System\Console\Tool
.
" "
.
(
count
(
$result
)
-
count
(
$recipients
))
.
" users have no e-mail address and are ignored."
);
$this
->
writeLn
(
"
\n\n
Is everything correct? (Y/n): "
);
// TEST MAIL
$this
->
writeLn
(
"
\n\n
Send test mail? (Y/n): "
);
$testMail
=
mb_strtolower
(
$this
->
readInput
())
!==
'n'
;
if
(
$testMail
)
{
$this
->
writeLn
(
"Test e-mail address: "
);
$testEmailAddress
=
$this
->
readInput
();
if
(
!
empty
(
$testEmailAddress
))
{
$this
->
writeLn
(
"
\n
Send test mail..."
);
$this
->
sendMails
(
$body
,
$senderMail
,
$senderName
,
$subject
,
[
0
=>
[
'username'
=>
'Test-User'
,
'email'
=>
$testEmailAddress
]
]
);
$this
->
write
(
" SENT!"
);
}
}
// CONFIRM AND SEND E-MAILS
$this
->
writeLn
(
"
\n\n
Is everything correct? Send e-mails NOW? (Y/n): "
);
$confirm
=
mb_strtolower
(
$this
->
readInput
())
!==
'n'
;
if
(
!
$confirm
)
{
...
...
@@ -152,6 +179,21 @@ class SendUserMails extends QUI\System\Console\Tool
return
;
}
$this
->
sendMails
(
$body
,
$senderMail
,
$senderName
,
$subject
,
$recipients
);
$this
->
exitSuccess
();
}
/**
* @param string $body
* @param string $senderMail
* @param string $senderName
* @param string $subject
* @param array $recipients
* @return void
*/
protected
function
sendMails
(
$body
,
$senderMail
,
$senderName
,
$subject
,
$recipients
)
{
// Queue mails
foreach
(
$recipients
as
$recipient
)
{
if
(
!
empty
(
$recipient
[
'firstname'
])
&&
!
empty
(
$recipient
[
'lastname'
]))
{
...
...
@@ -173,14 +215,12 @@ class SendUserMails extends QUI\System\Console\Tool
$Mailer
->
setFromName
(
$senderName
);
$Mailer
->
setSubject
(
$subject
);
$Mailer
->
setHTML
(
true
);
$Mailer
->
setBody
(
$body
);
$Mailer
->
addRecipient
(
$email
);
$Mailer
->
send
();
}
$this
->
exitSuccess
();
}
/**
...
...
Write
Preview
Markdown
is supported
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