When configuring email systems like SpamAssassin or implementing IMAP clients, one common question arises: should we use "Junk" or "Spam" as the standard folder name for unwanted messages? This decision affects compatibility across various email clients and server configurations.
After examining major email clients and servers, we find:
- Roundcube: Uses "Junk" by default
- Microsoft Outlook: Traditionally uses "Junk"
- Gmail: Uses "Spam"
- Apple Mail: Uses "Junk"
For maximum compatibility, consider implementing both folder names and using IMAP SPECIAL-USE attributes:
// Example IMAP configuration supporting both names
if (!imap_createmailbox($connection, "INBOX.Junk")) {
imap_createmailbox($connection, "INBOX.Spam");
}
// Alternative using SPECIAL-USE
$special_use = array(
'\Junk' => 'INBOX.Junk',
'\Trash' => 'INBOX.Trash',
'\Sent' => 'INBOX.Sent',
'\Drafts' => 'INBOX.Drafts'
);
The most widely recognized standard folder names are:
INBOX
Sent
Trash
Drafts
Junk (or Spam)
Some clients allow customization through configuration files. For Roundcube:
// roundcube/config/config.inc.php
$config['junk_mbox'] = 'INBOX.Spam'; // or 'INBOX.Junk'
$config['trash_mbox'] = 'INBOX.Trash';
$config['sent_mbox'] = 'INBOX.Sent';
$config['drafts_mbox'] = 'INBOX.Drafts';
Based on cross-client compatibility analysis:
- Primary recommendation: Use "Junk" as it's more widely supported
- Secondary option: Implement both names with proper SPECIAL-USE attributes
- Document your choice in system configuration files
When working with IMAP servers, you might need to check folder existence:
function ensure_imap_folders($connection) {
$required_folders = array('INBOX', 'Sent', 'Trash', 'Drafts', 'Junk');
foreach ($required_folders as $folder) {
if (!imap_getmailboxes($connection, '{imap.example.com}', $folder)) {
imap_createmailbox($connection, imap_utf7_encode('{imap.example.com}'.$folder));
}
}
}
When configuring email servers and spam filtering systems like SpamAssassin, one common question arises: Should we use "Junk" or "Spam" as the standard folder name for unwanted messages? While both terms are widely understood, their usage varies across different email clients and platforms.
The Internet Message Access Protocol (IMAP) itself doesn't mandate specific folder names, but several RFCs and common practices have emerged:
- RFC 6154 recommends special-use mailbox names but doesn't specify between Junk/Spam
- Microsoft Exchange and Outlook traditionally use "Junk Email"
- Gmail uses "Spam" (though it's not standard IMAP)
- Apple Mail uses "Junk"
- Roundcube (as you noted) defaults to "Junk"
From a compatibility perspective, "Junk" appears to be the safer choice for several reasons:
// Example IMAP folder configuration for maximum compatibility
$standard_folders = [
'inbox' => 'INBOX',
'sent' => 'Sent',
'drafts' => 'Drafts',
'trash' => 'Trash',
'junk' => 'Junk' // Preferred over 'Spam'
];
When configuring SpamAssassin to work with IMAP folders, you can specify the target folder in your configuration:
# In local.cf or similar SpamAssassin config file
rewrite_header Subject *****SPAM*****
add_header all Status YES
add_header all X-Spam-Flag YES
add_header all X-Spam-Folder Junk # Using 'Junk' here
For systems serving diverse clients, consider these approaches:
- Create both folders and use server-side rules to keep them synchronized
- Implement folder alias functionality if your IMAP server supports it
- Detect client type during login and present the appropriate folder name
If you need to change existing folder names, here's a basic IMAP rename operation example:
# Using IMAP command line (replace with your server's syntax)
a SELECT "Spam"
a RENAME "Spam" "Junk"
a LOGOUT
Remember to update any client-side rules or filters that might reference the old folder name.