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
232a223c
Commit
232a223c
authored
Jan 08, 2014
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SwiftMailer message updated to setup charset for alternative body correctly.
parent
dc01411b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
Message.php
extensions/yii/swiftmailer/Message.php
+5
-3
MessageTest.php
tests/unit/extensions/swiftmailer/MessageTest.php
+19
-0
No files found.
extensions/yii/swiftmailer/Message.php
View file @
232a223c
...
@@ -188,6 +188,7 @@ class Message extends BaseMessage
...
@@ -188,6 +188,7 @@ class Message extends BaseMessage
{
{
$message
=
$this
->
getSwiftMessage
();
$message
=
$this
->
getSwiftMessage
();
$oldBody
=
$message
->
getBody
();
$oldBody
=
$message
->
getBody
();
$charset
=
$message
->
getCharset
();
if
(
empty
(
$oldBody
))
{
if
(
empty
(
$oldBody
))
{
$parts
=
$message
->
getChildren
();
$parts
=
$message
->
getChildren
();
$partFound
=
false
;
$partFound
=
false
;
...
@@ -195,6 +196,7 @@ class Message extends BaseMessage
...
@@ -195,6 +196,7 @@ class Message extends BaseMessage
if
(
!
(
$part
instanceof
\Swift_Mime_Attachment
))
{
if
(
!
(
$part
instanceof
\Swift_Mime_Attachment
))
{
/* @var \Swift_Mime_MimePart $part */
/* @var \Swift_Mime_MimePart $part */
if
(
$part
->
getContentType
()
==
$contentType
)
{
if
(
$part
->
getContentType
()
==
$contentType
)
{
$charset
=
$part
->
getCharset
();
unset
(
$parts
[
$key
]);
unset
(
$parts
[
$key
]);
$partFound
=
true
;
$partFound
=
true
;
break
;
break
;
...
@@ -204,7 +206,7 @@ class Message extends BaseMessage
...
@@ -204,7 +206,7 @@ class Message extends BaseMessage
if
(
$partFound
)
{
if
(
$partFound
)
{
reset
(
$parts
);
reset
(
$parts
);
$message
->
setChildren
(
$parts
);
$message
->
setChildren
(
$parts
);
$message
->
addPart
(
$body
,
$contentType
);
$message
->
addPart
(
$body
,
$contentType
,
$charset
);
}
else
{
}
else
{
$message
->
setBody
(
$body
,
$contentType
);
$message
->
setBody
(
$body
,
$contentType
);
}
}
...
@@ -215,8 +217,8 @@ class Message extends BaseMessage
...
@@ -215,8 +217,8 @@ class Message extends BaseMessage
}
else
{
}
else
{
$message
->
setBody
(
null
);
$message
->
setBody
(
null
);
$message
->
setContentType
(
null
);
$message
->
setContentType
(
null
);
$message
->
addPart
(
$oldBody
,
$oldContentType
);
$message
->
addPart
(
$oldBody
,
$oldContentType
,
$charset
);
$message
->
addPart
(
$body
,
$contentType
);
$message
->
addPart
(
$body
,
$contentType
,
$charset
);
}
}
}
}
}
}
...
...
tests/unit/extensions/swiftmailer/MessageTest.php
View file @
232a223c
...
@@ -341,4 +341,23 @@ class MessageTest extends VendorTestCase
...
@@ -341,4 +341,23 @@ class MessageTest extends VendorTestCase
$unserializedMessaage
=
unserialize
(
$serializedMessage
);
$unserializedMessaage
=
unserialize
(
$serializedMessage
);
$this
->
assertEquals
(
$message
,
$unserializedMessaage
,
'Unable to unserialize message!'
);
$this
->
assertEquals
(
$message
,
$unserializedMessaage
,
'Unable to unserialize message!'
);
}
}
/**
* @depends testSendAlternativeBody
*/
public
function
testAlternativeBodyCharset
()
{
$message
=
$this
->
createTestMessage
();
$charset
=
'windows-1251'
;
$message
->
setCharset
(
$charset
);
$message
->
setTextBody
(
'some text'
);
$message
->
setHtmlBody
(
'some html'
);
$content
=
$message
->
toString
();
$this
->
assertEquals
(
2
,
substr_count
(
$content
,
$charset
),
'Wrong charset for alternative body.'
);
$message
->
setTextBody
(
'some text override'
);
$content
=
$message
->
toString
();
$this
->
assertEquals
(
2
,
substr_count
(
$content
,
$charset
),
'Wrong charset for alternative body override.'
);
}
}
}
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