Skip to content

Commit

Permalink
PHPMailer: archiving not sent mails with prefix not_sent (#5321)
Browse files Browse the repository at this point in the history
  • Loading branch information
skerbis committed Aug 29, 2022
1 parent 21dad9e commit f031d4b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions redaxo/src/addons/phpmailer/lib/mailer.php
Expand Up @@ -129,6 +129,9 @@ public function send()
if ($addon->getConfig('logging')) {
$this->log('ERROR');
}
if ($this->archive) {
$this->archive($this->getSentMIMEMessage(), 'not_sent_');
}
return false;
}

Expand Down Expand Up @@ -195,13 +198,13 @@ public function setArchive(bool $status)
$this->archive = $status;
}

private function archive(string $archivedata = ''): void
private function archive(string $archivedata = '', string $status = ''): void
{
$dir = self::logFolder().'/'.date('Y').'/'.date('m');
$count = 1;
$archiveFile = $dir.'/'.date('Y-m-d_H_i_s').'.eml';
$archiveFile = $dir.'/'.$status.date('Y-m-d_H_i_s').'.eml';
while (is_file($archiveFile)) {
$archiveFile = $dir.'/'.date('Y-m-d_H_i_s').'_'.(++$count).'.eml';
$archiveFile = $dir.'/'.$status.date('Y-m-d_H_i_s').'_'.(++$count).'.eml';
}

rex_file::put($archiveFile, $archivedata);
Expand Down

0 comments on commit f031d4b

Please sign in to comment.