I haven't looked at the pmg-log-tracker code yet but might need to do that later if I make more changes.
If I'm going to read into that code I'll get back to you.
Maybe you will need to think also on the regulation/law that are in place for your country/region. In my own opinion to log any subject for any mail a bit more intrusive. Any mail is a privet communication if at least one side is a human. Think for a moment, that sameone as a person receive a mail with subject "you have X illness ". And you store this info or you use this info, because you can. At least in EU you can not do it legal because you do not work let say in madical/health field. But you do it because you can. So to be complied with EU GDPR you will need (I am not a expert in this field) to declare that you store medical / helth information because you want to do this.
So maybe I am wrong, but I suggest to speak with a lawyer about this.
And as a personal ideea, I have not think that if I have o problem to solve about mails, I must invade the privacy of my clients because I can do it !
Many managers ask me to show the mail from/to X . I say for any request that I can not do this. The subject of mails could be the first stpep.
For sure my response is not objective, because I liveing in a former communist country, where is was very common that our mail envelop that you send to any country to be inspected and rediding by communists employees. At the first step they read the receive address from the envelop (like subject for mails),
So the question is you must do it? I am pretty sure that are many proxmox users from countries where this kind of feature will be bery useful.... But in the end we must think if we want to destroy the life of such unlucky persons.
And this is not a supposition from my point of view. I see this with my own eyes a long time ago. But I care about this ... so I dare to say all of this.
Do you care? This is the question!
Sorry to all if I say bad things, it is not my intention at all.
So this option should be available in three options: 1. disable (default), 2. enable, 3. 4-eyes-principle (requires two login phrases to access information), that may also include senders and recipients (per option)
Maybe it's an better solution to log only the subject if the email is blocked or Quarantined? I think there is no need to store such Infos, if the mail was correctly forwarded to the recipient.
SpamExperts logged all information from a mail, but you are only able to see the whole mail if it is blocked, otherwise you can't see the whole mail.
Well, /usr/bin/pmg-smtp-filter is a python script which you can edit with your favorite editor.
What i changed:
First, add this somewhere between the 'use' statements at the beginning of the file:
use PVE::Tools;
Then search for this line:
$self->log (3, "$queue->{logid}: new mail message-id=%s", $queue->{msgid});
Add the following below that line:
$self->log (3, "$queue->{logid}: Subject: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($entity->head->get('subject'))) || 'No Subject');
my @fromarray = split('\s*,\s*', $entity->head->get('from') || $msginfo->{sender});
$self->log (3, "$queue->{logid}: From: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($fromarray[0])) );
This will log both the Subject and the From header from the mail.
pmg-log-tracker just works with that. I didn't have to adjust it.
Well, /usr/bin/pmg-smtp-filter is a python script which you can edit with your favorite editor.
What i changed:
First, add this somewhere between the 'use' statements at the beginning of the file:
use PVE::Tools;
Then search for this line:
$self->log (3, "$queue->{logid}: new mail message-id=%s", $queue->{msgid});
Add the following below that line:
$self->log (3, "$queue->{logid}: Subject: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($entity->head->get('subject'))) || 'No Subject');
my @fromarray = split('\s*,\s*', $entity->head->get('from') || $msginfo->{sender});
$self->log (3, "$queue->{logid}: From: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($fromarray[0])) );
This will log both the Subject and the From header from the mail.
pmg-log-tracker just works with that. I didn't have to adjust it.
Well, /usr/bin/pmg-smtp-filter is a python script which you can edit with your favorite editor.
What i changed:
First, add this somewhere between the 'use' statements at the beginning of the file:
use PVE::Tools;
Then search for this line:
$self->log (3, "$queue->{logid}: new mail message-id=%s", $queue->{msgid});
Add the following below that line:
$self->log (3, "$queue->{logid}: Subject: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($entity->head->get('subject'))) || 'No Subject');
my @fromarray = split('\s*,\s*', $entity->head->get('from') || $msginfo->{sender});
$self->log (3, "$queue->{logid}: From: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($fromarray[0])) );
This will log both the Subject and the From header from the mail.
pmg-log-tracker just works with that. I didn't have to adjust it.