Skip to content

Commit

Permalink
delete mails when processed
Browse files Browse the repository at this point in the history
  • Loading branch information
antedebaas committed Dec 30, 2023
1 parent dfaa93a commit 411950d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ MAILER_DSN=null://null

MAILBOX_CONNECTION=
MAILBOX_USERNAME=
MAILBOX_PASSWORD=
MAILBOX_PASSWORD=

DELETE_PROCESSED_MAILS=
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ MAILER_DSN=null://null

MAILBOX_CONNECTION="localhost:993/imap/ssl"
MAILBOX_USERNAME="[email protected]"
MAILBOX_PASSWORD="password"
MAILBOX_PASSWORD="password"
DELETE_PROCESSED_MAILS=false
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ENV MAILER_SMTPPORT=25
ENV MAILER_IMAPPORT=993
ENV MAILER_USER=
ENV MAILER_PASSWORD=
ENV DELETE_PROCESSED_MAILS=

RUN apk --update add ca-certificates
RUN apk --no-cache add \
Expand Down
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
app.mailbox_username: '%env(MAILBOX_USERNAME)%'
app.delete_processed_mails: '%env(DELETE_PROCESSED_MAILS)%'

services:
# default configuration for services in *this* file
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/containerstartup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if [ ! -f "/var/www/html/.env.local" ]; then
echo "MAILBOX_CONNECTION=\"$MAILER_HOST:$MAILER_IMAPPORT/imap/ssl\"" >> /var/www/html/.env.local
echo "MAILBOX_USERNAME=\"$MAILER_USER\"" >> /var/www/html/.env.local
echo "MAILBOX_PASSWORD=\"$MAILER_PASSWORD\"" >> /var/www/html/.env.local
echo "DELETE_PROCESSED_MAILS=\"$DELETE_PROCESSED_MAILS\"" >> /var/www/html/.env.local
fi

echo "Run migrations"
Expand Down
3 changes: 3 additions & 0 deletions src/Command/CheckmailboxCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ private function open_mailbox(Imap $imap):array
$smtptls_reports = array_merge($smtptls_reports,$new_reports['smtptls_reports']);
unlink($attachment->filePath);
}
if ($this->getParameter('app.delete_processed_mails') == true) {
$mailbox->deleteMail($mailId);
}
}
return array('num_emails' => $num_emails, 'reports' => array('dmarc_reports' => $dmarc_reports, 'smtptls_reports' => $smtptls_reports));
}
Expand Down

0 comments on commit 411950d

Please sign in to comment.