---
title: 'antispam:train'
url: 'https://docs.danami.com/warden/command-line-interface/antispam/antispam-train'
markdown: 'https://docs.danami.com/warden/command-line-interface/antispam/antispam-train.md'
date: '2026-10-07'
description: 'Perform Bayes training from the command line interface. Make sure that the location of maildirs PLESK_MAILNAMES_D is set properly in /etc/psa/psa.conf if you have changed the location of the maildirs directory. warden --task=antispam:train --oper=<train_spam|train_junk|train_ham|untrai…'
taxonomy:
  category:
    - docs
  tag:
    - bayes
---

[](#)  [ Basics ](https://docs.danami.com/warden/)     [ Command Line Interface ](https://docs.danami.com/warden/command-line-interface)      Antispam       antispam:train    

# antispam:train

Perform Bayes training from the command line interface.

> > > > > Make sure that the location of maildirs `PLESK_MAILNAMES_D` is set properly in `/etc/psa/psa.conf` if you have changed the location of the maildirs directory.

```
warden --task=antispam:train --oper=<train_spam|train_junk|train_ham|untrain_spam|untrain_junk|untrain_ham|force_expire|statistics|reset_training>
```

| Option | Value | Description |
|---|---|---|
| `--oper` | <string> | The operation you want to perform. Operations: train\_spam - Train Bayes using read mail from the users spam folder. train\_junk - Train Bayes using read mail from the users junk folder. train\_ham - Train Bayes using read mail from the users inbox. untrain\_spam - Forget trained read mail from the users spam folder. untrain\_junk - Forget trained read mail from the users junk folder. untrain\_ham - Forget trained read mail from the users inbox. force\_expire - Force expire old tokens from the database. statistics - View bayes training statistics. reset\_training - Delete all bayes tokens from the database. |
| `--domains` | <string1,string2> | The domains to use for Bayes training. Use 'all' for all domains. |
| `--mailboxes` | <string1,string2> | The mailboxes to use for Bayes training. |
| `--max_days` | <digit> | The maximum number of days of mail to include in training. Spam training will default to the last 30 days. Ham training will default to the last 7 days. |
| `--max_size` | <digit> | Skip messages larger than this size (in KB). Defaults to 500KB, Use 0 for no limit. |
| `--debug` | <string1,string2> | Print debugging messages (area1,area2). Use 'all' for all areas. |
| `--progress` | <1\|0> | Show/hide a progress indicator when training. |

## Examples

```
// train spam for all domains
warden --task=antispam:train --oper=train_spam --domains=all

// train junk for all domains
warden --task=antispam:train --oper=train_junk --domains=all

// train ham for all domains
warden --task=antispam:train --oper=train_ham --domains=all

// train spam for specific domains
warden --task=antispam:train --oper=train_spam --domains=example1.com,example2.com

// train junk for specific domains
warden --task=antispam:train --oper=train_junk --domains=example1.com,example2.com

// train ham for specific domains
warden --task=antispam:train --oper=train_ham --domains=example1.com,example2.com

// train spam for specific mailboxes
warden --task=antispam:train --oper=train_spam --mailboxes=test@example1.com,test@example2.com

// train junk for specific mailboxes
warden --task=antispam:train --oper=train_junk --mailboxes=test@example1.com,test@example2.com

// train ham for specific mailboxes
warden --task=antispam:train --oper=train_ham --mailboxes=test@example1.com,test@example2.com

// train ham for a specific mailbox using the last 30 days of read mail with a max size of 1000 KB.
warden --task=antispam:train --oper=train_ham --mailboxes=test@example.com --max_days=30 --max_size=1000

// force expire of old tokens out of the database
warden --task=antispam:train --oper=force_expire

// get training statistics
warden --task=antispam:train --oper=statistics

// delete all bayes training data from the database
warden --task=antispam:train --oper=reset_training

// retrain from the last 14 days of spam for the two most complained domains, skipping messages over 1 MB
warden --task=antispam:train --oper=train_spam --domains=example.com,example2.com --max_days=14 --max_size=1024 --progress=1
```

## Related Pages

- [Training Settings](https://docs.danami.com/warden/settings/antispam/training-settings "Training Settings")

 [](https://docs.danami.com/warden/command-line-interface/antispam/antispam-training)

---

## Navigation

- Previous: [antispam:ruleupdates](https://docs.danami.com/warden/command-line-interface/antispam/antispam-ruleupdates.md)
- Next: [antispam:training](https://docs.danami.com/warden/command-line-interface/antispam/antispam-training.md)
