[SOLVED] How one mark as spam/ham mail from external mailserver+webmail

outer_network

New Member
Feb 8, 2026
3
0
1
Hello,

Thank you for wounderful software, it fit very well in place where zimbra would be (with extra steps and only as a cog in bigger machine).

I move message based on user mailbox interaction with /Spam folder. If he mark mail as spam the copy of message is sent to spam@ if messages is marked as ham copy goes to ham@.

How can I pass those message to push them to proper learning spam/ham into pmg ?

Edit: looks like there is no build-in learning feature. From what I'm reading old threads...

But I'm still curios how to tackle this issue.
 
Last edited:
Hallo

The Spam mailbox is probably on your mail server, while the mail gateway is a separate system.

I have solved this by
  1. setting up a mail account `spam@...` on the mail server
    1. I move/copy all Spam to the subfolder `Spam` there ASAP.
    2. I also copied some good mail to `Ham` there for a start.
  2. writing a program that
    1. runs every hour on the mail gateway
    2. connects to the spam mailbox
    3. learns every mail in the sub folders `Spam` and `Ham`.
    4. Deletes the mail after.
Let me know if you are interested in trying this route.

Cheers
M
 
Last edited:
Hallo

The Spam mailbox is probably on your mail server, while the mail gateway is a separate system.

I have solved this program by
  1. setting up a mail account `spam@...` on the mail server
    1. I move/copy all Spam to the subfolder `Spam` there ASAP.
    2. I also copied some good mail to `Ham` there for a start.
  2. writing a program that
    1. runs every hour on the mail gateway
    2. connects to the spam mailbox
    3. learns every mail in the sub folders `Spam` and `Ham`.
    4. Deletes the mail after.
Let me know if you are interested in trying this route.

Cheers
M
I'm almost there. I did build spam/ham folder on different account hat aggreate those things.
Learning part is the hardest. Do I need to learn via attachments of those mails (send with report function) or do you copy .msg file over to new account ?
what command you use for learning ?
 
for anyone doing this like I did.
You have to build your solution in your own way because there is no working out-of-the-box solution.

You could:
use doveadm on mail server to find HAM/SPAM, move it to your ham/spam account
later, from pmg use mail client/rsync those mails and process them on pmg
while being on pmg you could use pmgsh to process those mails thru pmg system

You will have to tweak pmg ruls, write bit of scripts, install few crons. maybe even have few smaller (sqlite) databases and as the journey go you will tweak this... but this is the way of a sysadmin ;-)
 
Have you seen that old thread?
https://forum.proxmox.com/threads/train-spamasssassin-with-mail-of-an-imap-mailbox.49125/

Also:
https://github.com/magenbrot/sa_learn_from_imap

I did something similar in the past: on the mail server, I had shared (IMAP) folders named Spam and Ham. Users could move/copy ham and spam mails into these folders accordingly, no other action needed. The learning process (in this case running on the PMG server because that is where SA lives) picks them up frequently and removes processed emails... I also believe some mail clients like Roundcube have plugins, that move or forward ham/spam to configured folders or accounts if needed. But I have no experience with web clients.
 
Last edited: