Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
mathieu
potage
Commits
fe2726cd
Commit
fe2726cd
authored
Aug 27, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
envoi de mail, parse le champs TO: nom prenom <email@domain.tld>
parent
ac79ff07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
24 deletions
+27
-24
src/PotageBundle/Command/SendMailCommand.php
src/PotageBundle/Command/SendMailCommand.php
+7
-8
src/PotageBundle/Resources/views/Mail/bodyMail.html.twig
src/PotageBundle/Resources/views/Mail/bodyMail.html.twig
+1
-0
src/PotageBundle/Services/Newsletter.php
src/PotageBundle/Services/Newsletter.php
+19
-16
No files found.
src/PotageBundle/Command/SendMailCommand.php
View file @
fe2726cd
...
...
@@ -54,13 +54,12 @@ class SendMailCommand extends ContainerAwareCommand
->
getRepository
(
'PotageBundle:Lettre'
)
->
findOneForSend
(
7
);
$ret
=
$this
->
newsletter
->
sendLettreToGroup
(
$lettre
,
'body du mail de test'
);
$retMsg
=
(
$ret
===
1
)
?
"
\e
[1;32mDone
\e
[0m
\n
"
:
"
\e
[1;31mError
\e
[0m
\n
"
;
$output
->
writeln
(
'Sending mail .. '
.
$retMsg
);
$retour
=
$this
->
newsletter
->
sendLettreToGroup
(
$lettre
,
'body du mail de test. Mail envoyé depuis la ligne de commande '
);
for
(
$i
=
0
;
$i
<
count
(
$retour
);
$i
++
)
{
$output
->
writeln
(
$i
.
' | '
.
$retour
[
$i
][
'to'
]
.
' | '
.
$retour
[
$i
][
'result'
]);
}
}
}
src/PotageBundle/Resources/views/Mail/bodyMail.html.twig
View file @
fe2726cd
...
...
@@ -22,6 +22,7 @@
<h1>
Mon template twig
</h1>
<h2>
{{
subject
}}
</h2>
<h3>
{{
to
}}
</h3>
{{
body
}}
</body>
</html>
\ No newline at end of file
src/PotageBundle/Services/Newsletter.php
View file @
fe2726cd
...
...
@@ -21,7 +21,17 @@ class Newsletter
}
/**
* @param $to
* @param array $email
* @return string
*/
private
function
parseMail
(
array
$email
)
{
return
$email
[
'fullName'
]
.
'<'
.
$email
[
'email'
]
.
'>'
;
}
/**
* @param array $to
* @param $subject
* @param $body
* @return int
...
...
@@ -40,12 +50,12 @@ class Newsletter
$message
=
(
new
\
Swift_Message
())
->
setFrom
(
$from
)
->
setTo
(
$to
)
->
setTo
(
$to
[
'email'
],
$to
[
'fullName'
]
)
->
setSubject
(
$subject
)
->
setBody
(
$twig
->
render
(
'@Potage/Mail/bodyMail.html.twig'
,
array
(
'body'
=>
$body
,
'to'
=>
$t
o
,
'to'
=>
$t
his
->
parseMail
(
$to
)
,
'subject'
=>
$subject
)),
'text/html'
...
...
@@ -76,22 +86,15 @@ class Newsletter
$ret
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$utilisateurs
);
$i
++
)
{
//$email = array(
// $utilisateurs[$i]['email'] => $utilisateurs[$i]['prenom'] . ' ' . $utilisateurs[$i]['nom']
//);
$email
=
$utilisateurs
[
$i
][
'email'
];
//dump($email);
$to
=
array
(
'fullName'
=>
$utilisateurs
[
$i
][
'prenom'
]
.
' '
.
$utilisateurs
[
$i
][
'nom'
],
'email'
=>
$utilisateurs
[
$i
][
'email'
]
);
$ret
[
$i
]
=
array
(
'to'
=>
$
email
,
'result'
=>
$this
->
sendMail
(
$
email
,
$subject
,
$body
)
===
1
?
'done'
:
'error'
'to'
=>
$
this
->
parseMail
(
$to
)
,
'result'
=>
$this
->
sendMail
(
$
to
,
$subject
,
$body
)
===
1
?
'done'
:
'error'
);
}
return
$ret
;
}
...
...
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