Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
3838b501
Commit
3838b501
authored
Apr 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored Debug Mail panel to work with different vendors
implementation checks for instanceof for additional swiftmailer capabilities. issue #2870
parent
4c09aef2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
main.css
extensions/debug/assets/main.css
+5
-0
MailPanel.php
extensions/debug/panels/MailPanel.php
+23
-12
No files found.
extensions/debug/assets/main.css
View file @
3838b501
...
...
@@ -38,6 +38,11 @@ td, th {
word-break
:
break-all
;
}
.not-set
{
color
:
#c55
;
font-style
:
italic
;
}
.detail-grid-view
th
{
white-space
:
nowrap
;
}
...
...
extensions/debug/panels/MailPanel.php
View file @
3838b501
...
...
@@ -13,6 +13,7 @@ use yii\debug\models\search\Mail;
use
yii\debug\Panel
;
use
yii\mail\BaseMailer
;
use
yii\helpers\FileHelper
;
use
yii\mail\MessageInterface
;
/**
* Debugger panel that collects and displays the generated emails.
...
...
@@ -39,27 +40,37 @@ class MailPanel extends Panel
parent
::
init
();
Event
::
on
(
BaseMailer
::
className
(),
BaseMailer
::
EVENT_AFTER_SEND
,
function
(
$event
)
{
$message
=
$event
->
message
->
getSwiftMessage
();
$textBody
=
$message
->
getBody
();
$fileName
=
$event
->
sender
->
generateMessageFileName
();
FileHelper
::
createDirectory
(
Yii
::
getAlias
(
$this
->
mailPath
));
file_put_contents
(
Yii
::
getAlias
(
$this
->
mailPath
)
.
'/'
.
$fileName
,
$message
->
toString
());
$this
->
_messages
[]
=
[
/** @var MessageInterface $message */
$message
=
$event
->
message
;
$messageData
=
[
'isSuccessful'
=>
$event
->
isSuccessful
,
'time'
=>
$message
->
getDate
(),
'headers'
=>
$message
->
getHeaders
(),
'from'
=>
$this
->
convertParams
(
$message
->
getFrom
()),
'to'
=>
$this
->
convertParams
(
$message
->
getTo
()),
'reply'
=>
$this
->
convertParams
(
$message
->
getReplyTo
()),
'cc'
=>
$this
->
convertParams
(
$message
->
getCc
()),
'bcc'
=>
$this
->
convertParams
(
$message
->
getBcc
()),
'subject'
=>
$message
->
getSubject
(),
'body'
=>
$textBody
,
'charset'
=>
$message
->
getCharset
(),
'file'
=>
$fileName
,
];
// add more information when message is a SwiftMailer message
if
(
$message
instanceof
\yii\swiftmailer\Message
)
{
/** @var \Swift_Message $swiftMessage */
$swiftMessage
=
$message
->
getSwiftMessage
();
$messageData
[
'body'
]
=
$swiftMessage
->
getBody
();
$messageData
[
'time'
]
=
$swiftMessage
->
getDate
();
$messageData
[
'headers'
]
=
$swiftMessage
->
getHeaders
();
}
// store message as file
$fileName
=
$event
->
sender
->
generateMessageFileName
();
FileHelper
::
createDirectory
(
Yii
::
getAlias
(
$this
->
mailPath
));
file_put_contents
(
Yii
::
getAlias
(
$this
->
mailPath
)
.
'/'
.
$fileName
,
$message
->
toString
());
$messageData
[
'file'
]
=
$fileName
;
$this
->
_messages
[]
=
$messageData
;
});
}
...
...
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