@@ -288,6 +288,13 @@ class Email
288
288
*/
289
289
protected $ debugMessage = [];
290
290
291
+ /**
292
+ * Raw debug messages
293
+ *
294
+ * @var string[]
295
+ */
296
+ private array $ debugMessageRaw = [];
297
+
291
298
/**
292
299
* Recipients
293
300
*
@@ -434,16 +441,17 @@ public function initialize($config)
434
441
*/
435
442
public function clear ($ clearAttachments = false )
436
443
{
437
- $ this ->subject = '' ;
438
- $ this ->body = '' ;
439
- $ this ->finalBody = '' ;
440
- $ this ->headerStr = '' ;
441
- $ this ->replyToFlag = false ;
442
- $ this ->recipients = [];
443
- $ this ->CCArray = [];
444
- $ this ->BCCArray = [];
445
- $ this ->headers = [];
446
- $ this ->debugMessage = [];
444
+ $ this ->subject = '' ;
445
+ $ this ->body = '' ;
446
+ $ this ->finalBody = '' ;
447
+ $ this ->headerStr = '' ;
448
+ $ this ->replyToFlag = false ;
449
+ $ this ->recipients = [];
450
+ $ this ->CCArray = [];
451
+ $ this ->BCCArray = [];
452
+ $ this ->headers = [];
453
+ $ this ->debugMessage = [];
454
+ $ this ->debugMessageRaw = [];
447
455
448
456
$ this ->setHeader ('Date ' , $ this ->setDate ());
449
457
@@ -1658,7 +1666,12 @@ protected function spoolEmail()
1658
1666
}
1659
1667
1660
1668
if (! $ success ) {
1661
- $ this ->setErrorMessage (lang ('Email.sendFailure ' . ($ protocol === 'mail ' ? 'PHPMail ' : ucfirst ($ protocol ))));
1669
+ $ message = lang ('Email.sendFailure ' . ($ protocol === 'mail ' ? 'PHPMail ' : ucfirst ($ protocol )));
1670
+
1671
+ log_message ('error ' , 'Email: ' . $ message );
1672
+ log_message ('error ' , $ this ->printDebuggerRaw ());
1673
+
1674
+ $ this ->setErrorMessage ($ message );
1662
1675
1663
1676
return false ;
1664
1677
}
@@ -1937,7 +1950,8 @@ protected function sendCommand($cmd, $data = '')
1937
1950
1938
1951
$ reply = $ this ->getSMTPData ();
1939
1952
1940
- $ this ->debugMessage [] = '<pre> ' . $ cmd . ': ' . $ reply . '</pre> ' ;
1953
+ $ this ->debugMessage [] = '<pre> ' . $ cmd . ': ' . $ reply . '</pre> ' ;
1954
+ $ this ->debugMessageRaw [] = $ cmd . ': ' . $ reply ;
1941
1955
1942
1956
if ($ resp === null || ((int ) static ::substr ($ reply , 0 , 3 ) !== $ resp )) {
1943
1957
$ this ->setErrorMessage (lang ('Email.SMTPError ' , [$ reply ]));
@@ -2090,8 +2104,8 @@ protected function getHostname()
2090
2104
}
2091
2105
2092
2106
/**
2093
- * @param array $include List of raw data chunks to include in the output
2094
- * Valid options are: 'headers', 'subject', 'body'
2107
+ * @param array|string $include List of raw data chunks to include in the output
2108
+ * Valid options are: 'headers', 'subject', 'body'
2095
2109
*
2096
2110
* @return string
2097
2111
*/
@@ -2119,12 +2133,21 @@ public function printDebugger($include = ['headers', 'subject', 'body'])
2119
2133
return $ msg . ($ rawData === '' ? '' : '<pre> ' . $ rawData . '</pre> ' );
2120
2134
}
2121
2135
2136
+ /**
2137
+ * Returns raw debug messages
2138
+ */
2139
+ private function printDebuggerRaw (): string
2140
+ {
2141
+ return implode ("\n" , $ this ->debugMessageRaw );
2142
+ }
2143
+
2122
2144
/**
2123
2145
* @param string $msg
2124
2146
*/
2125
2147
protected function setErrorMessage ($ msg )
2126
2148
{
2127
- $ this ->debugMessage [] = $ msg . '<br /> ' ;
2149
+ $ this ->debugMessage [] = $ msg . '<br /> ' ;
2150
+ $ this ->debugMessageRaw [] = $ msg ;
2128
2151
}
2129
2152
2130
2153
/**
0 commit comments