@@ -750,7 +750,7 @@ class PHPMailer
750750 *
751751 * @var string
752752 */
753- const VERSION = '6.6.5 ' ;
753+ const VERSION = '6.7.1 ' ;
754754
755755 /**
756756 * Error severity: message only, continue processing.
@@ -858,7 +858,7 @@ public function __destruct()
858858 private function mailPassthru ($ to , $ subject , $ body , $ header , $ params )
859859 {
860860 //Check overloading of mail function to avoid double-encoding
861- if (ini_get ('mbstring.func_overload ' ) & 1 ) {
861+ if (( int ) ini_get ('mbstring.func_overload ' ) & 1 ) {
862862 $ subject = $ this ->secureHeader ($ subject );
863863 } else {
864864 $ subject = $ this ->encodeHeader ($ this ->secureHeader ($ subject ));
@@ -1124,6 +1124,22 @@ protected function addOrEnqueueAnAddress($kind, $address, $name)
11241124 return call_user_func_array ([$ this , 'addAnAddress ' ], $ params );
11251125 }
11261126
1127+ /**
1128+ * Set the boundaries to use for delimiting MIME parts.
1129+ * If you override this, ensure you set all 3 boundaries to unique values.
1130+ * The default boundaries include a "=_" sequence which cannot occur in quoted-printable bodies,
1131+ * as suggested by https://www.rfc-editor.org/rfc/rfc2045#section-6.7
1132+ *
1133+ * @return void
1134+ */
1135+ public function setBoundaries ()
1136+ {
1137+ $ this ->uniqueid = $ this ->generateId ();
1138+ $ this ->boundary [1 ] = 'b1=_ ' . $ this ->uniqueid ;
1139+ $ this ->boundary [2 ] = 'b2=_ ' . $ this ->uniqueid ;
1140+ $ this ->boundary [3 ] = 'b3=_ ' . $ this ->uniqueid ;
1141+ }
1142+
11271143 /**
11281144 * Add an address to one of the recipient arrays or to the ReplyTo array.
11291145 * Addresses that have been added already return false, but do not throw exceptions.
@@ -1671,11 +1687,11 @@ public function postSend()
16711687 return $ this ->mailSend ($ this ->MIMEHeader , $ this ->MIMEBody );
16721688 }
16731689 } catch (Exception $ exc ) {
1690+ $ this ->setError ($ exc ->getMessage ());
1691+ $ this ->edebug ($ exc ->getMessage ());
16741692 if ($ this ->Mailer === 'smtp ' && $ this ->SMTPKeepAlive == true && $ this ->smtp ->connected ()) {
16751693 $ this ->smtp ->reset ();
16761694 }
1677- $ this ->setError ($ exc ->getMessage ());
1678- $ this ->edebug ($ exc ->getMessage ());
16791695 if ($ this ->exceptions ) {
16801696 throw $ exc ;
16811697 }
@@ -2407,7 +2423,7 @@ public function addrAppend($type, $addr)
24072423 */
24082424 public function addrFormat ($ addr )
24092425 {
2410- if (empty ($ addr [1 ])) { //No name provided
2426+ if (! isset ($ addr [1 ]) || ( $ addr [ 1 ] === '' )) { //No name provided
24112427 return $ this ->secureHeader ($ addr [0 ]);
24122428 }
24132429
@@ -2794,10 +2810,7 @@ public function createBody()
27942810 {
27952811 $ body = '' ;
27962812 //Create unique IDs and preset boundaries
2797- $ this ->uniqueid = $ this ->generateId ();
2798- $ this ->boundary [1 ] = 'b1_ ' . $ this ->uniqueid ;
2799- $ this ->boundary [2 ] = 'b2_ ' . $ this ->uniqueid ;
2800- $ this ->boundary [3 ] = 'b3_ ' . $ this ->uniqueid ;
2813+ $ this ->setBoundaries ();
28012814
28022815 if ($ this ->sign_key_file ) {
28032816 $ body .= $ this ->getMailMIME () . static ::$ LE ;
@@ -2833,7 +2846,7 @@ public function createBody()
28332846 $ altBodyEncoding = static ::ENCODING_QUOTED_PRINTABLE ;
28342847 }
28352848 //Use this as a preamble in all multipart message types
2836- $ mimepre = 'This is a multi-part message in MIME format. ' . static :: $ LE . static :: $ LE ;
2849+ $ mimepre = '' ;
28372850 switch ($ this ->message_type ) {
28382851 case 'inline ' :
28392852 $ body .= $ mimepre ;
@@ -3069,6 +3082,18 @@ public function createBody()
30693082 return $ body ;
30703083 }
30713084
3085+ /**
3086+ * Get the boundaries that this message will use
3087+ * @return array
3088+ */
3089+ public function getBoundaries ()
3090+ {
3091+ if (empty ($ this ->boundary )) {
3092+ $ this ->setBoundaries ();
3093+ }
3094+ return $ this ->boundary ;
3095+ }
3096+
30723097 /**
30733098 * Return the start of a message boundary.
30743099 *
@@ -4636,17 +4661,29 @@ public static function normalizeBreaks($text, $breaktype = null)
46364661 }
46374662
46384663 /**
4639- * Remove trailing breaks from a string.
4664+ * Remove trailing whitespace from a string.
46404665 *
46414666 * @param string $text
46424667 *
4643- * @return string The text to remove breaks from
4668+ * @return string The text to remove whitespace from
46444669 */
46454670 public static function stripTrailingWSP ($ text )
46464671 {
46474672 return rtrim ($ text , " \r\n\t" );
46484673 }
46494674
4675+ /**
4676+ * Strip trailing line breaks from a string.
4677+ *
4678+ * @param string $text
4679+ *
4680+ * @return string The text to remove breaks from
4681+ */
4682+ public static function stripTrailingBreaks ($ text )
4683+ {
4684+ return rtrim ($ text , "\r\n" );
4685+ }
4686+
46504687 /**
46514688 * Return the current line break format string.
46524689 *
@@ -4810,7 +4847,7 @@ public function DKIM_BodyC($body)
48104847 $ body = static ::normalizeBreaks ($ body , self ::CRLF );
48114848
48124849 //Reduce multiple trailing line breaks to a single one
4813- return static ::stripTrailingWSP ($ body ) . self ::CRLF ;
4850+ return static ::stripTrailingBreaks ($ body ) . self ::CRLF ;
48144851 }
48154852
48164853 /**
0 commit comments