summaryrefslogtreecommitdiffstats
path: root/lib/private/mail
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-17 19:41:13 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-17 19:41:13 +0100
commitaea4b3166baab48fbc36ce40dfc5481fc6ba45ab (patch)
tree38cac02bd33cd9119e92553881848d83973760be /lib/private/mail
parentebb834d879f10ea24b8cf032f6f0000076843195 (diff)
downloadnextcloud-server-aea4b3166baab48fbc36ce40dfc5481fc6ba45ab.tar.gz
nextcloud-server-aea4b3166baab48fbc36ce40dfc5481fc6ba45ab.zip
Add debug mode back to mailer
This re-adds the debug mode for the mailer which will log the whole SMTP traffic within the log file if enabled.
Diffstat (limited to 'lib/private/mail')
-rw-r--r--lib/private/mail/mailer.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/mail/mailer.php b/lib/private/mail/mailer.php
index a995322d89e..13c9167cabc 100644
--- a/lib/private/mail/mailer.php
+++ b/lib/private/mail/mailer.php
@@ -73,15 +73,30 @@ class Mailer implements IMailer {
* has been supplied.)
*/
public function send(Message $message) {
+ $debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
+
if (sizeof($message->getFrom()) === 0) {
$message->setFrom([\OCP\Util::getDefaultEmailAddress($this->defaults->getName())]);
}
$failedRecipients = [];
- $this->getInstance()->send($message->getSwiftMessage(), $failedRecipients);
+ $mailer = $this->getInstance();
+
+ // Enable logger if debug mode is enabled
+ if($debugMode) {
+ $mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
+ $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
+ }
+
+ $mailer->send($message->getSwiftMessage(), $failedRecipients);
+
+ // Debugging logging
$logMessage = sprintf('Sent mail to "%s" with subject "%s"', print_r($message->getTo(), true), $message->getSubject());
$this->logger->debug($logMessage, ['app' => 'core']);
+ if($debugMode && isset($mailLogger)) {
+ $this->logger->debug($mailLogger->dump(), ['app' => 'core']);
+ }
return $failedRecipients;
}