This program connects to the specified IMAP4 mail server, selects and reads the contents of a specified folder. The contents are then exported to a ``mbox'' compatible file. As the e-mails are read from the folder you may choose to delete those entries. This program is intended to assist in export ham folders and spam folders from Microsoft Exchange mail servers into the mbox format required by utilities such as SpamAssassin.
This program is was written to work with the IMAP4 RFC-2060 messaging protocol. This should be good news for the non-Exchange users - because it means that IMAP2MBOX should work for any RFC-2060 compliant server.
1.0.0.1 Initial release - Dennis Heidner
1.0.0.2 Added localtime to verbose, removed the check for "verbose" as a trigger to change timestamp in the config file. Also changed default config file path from d:\temp to ".\"
1.0.0.3 Local time added to verbose output. selected count fixed, messages at end modified when no mail entries were selected for export.
IMAP2MBOX [options] [file | value ...]
Options:
-folder name of the folder to examine, I.E. HAM or SPAM -path mail server path name for the folder, such as "Public Folders/" -mbox "mbox" mail container that will hold the exported e-mail -config brief help message -username e-mail account name, for example: 'domain_name/user/mailalias' -pass mail password for the username -server hostname of the mail server -port IMAP4 port for the server, typically port 143 -delete delete mail entry after it has been written to mbox. -man full documentation -help brief help message -verbose display mail server name, folder information and number of e-mails copied -version display version of this program.
--folder=Spam
--path='Public Folders/'
--mbox=spam.mbox
--config=spam.cfg or --config='.\spam.cfg'
--username='xyz_nw/johndoe/jd'
If the e-mail user name and alias are the same (sorry - Exchange 5.5 and earlier admins will undersand) then the username could be entered as:
--username='xyz_nw/johndoe'
--pass=smily
Creates the encrypted password string similar to:
NAQmuelxoeghewdbX1xRb0ZXX0BsXG1hcDJtYm94LmluaTIxNTUzMjIyMDA1V2VkTWFy MjE1NTMyMjIwMDU
--delete=1 <- delete the mail after exporting --delete=0 <- the default, leave the mail in the folder after exporting.
--verbose=0 <-- do not display progress or information about the server --verbose=1 <-- display minimal progress and some information about the server
This program connects to the specified IMAP4 mail server, selects and reads the contents of a specified folder. The contents are then exported to a ``mbox'' compatible file. As the e-mails are read from the folder you may choose to delete those entries. This program is intended to assist in export ham folders and spam folders from Microsoft Exchange mail servers into the mbox format required by utilities such as SpamAssassin.
This program is was written such that it reads from the IMAP4 server using the RFC-2060 standards. This should be good news for the non-Exchange users - because it means that IMAP2MBOX should work for any RFC-2060 compliant server.
IMAP2MBOX accepts configuration parameters from the command line. The configuration information is written into a configuration file for later use. This allows the adminstrator to create templates that can be used to read and export e-mails from public HAM and SPAM mailboxes.
For example, if a template had been previously saved. Running IMAP2MBOX might produce the bollowing:
>imap2mbox.exe --config=ham.ini The server is: mailserver. 11 E-mails to process / 10 - messages selected Extracting mail from: Public Folders/HAM is complete. Mail written to mbox: d:\temp\ham.mbox
The first time IMAP2MBOX is used, you should specify the servername, public folder, your mbox container name, e-mail user name and password. The password will be encrypted such that that it is not easy to decipher. If the config file is renamed or moved, the password encryption becomes invalidated thus requiring a password to be re-entered.
For example:
>imap2mbox.exe --config="d:\temp\ham.cfg" --path="Pubic Folders/" --folder="HAM" --server=mailserver --delete=1 --username="my_domain/userid/myalias" --mbox="d:\temp\ham.mbox" --pass=goodguess The server is: mailserver. 11 E-mails to process / 10 - messages selected Extracting mail from: Public Folders/HAM is complete. Mail written to mbox: d:\temp\ham.mbox
The resulting ``ham.cfg'' configuration file would look like:
[Server] Name=mailserver Port=143 [User] Name=my_domain/userid/alias Magic= <<EOT NAQmuelxoeghewdbX1xRb0ZXX0BsXG1hcDJtYm94LmluaTIxNTUzMjIyMDA1V2VkTWFy MjE1NTMyMjIwMDU= EOT [Public Box] Path=Public Folders/ Folder=HAM [Output] Mbox=d:\temp\ham.mbox [Options] Verbose=1 Delete=1 Timestamp=WedMar211236622005
The newly created IMAP2MBOX config file can be used as a template for additional tasks, for example:
>copy d:\temp\ham.cfg d:\temp\spam.cfg >imap2mbox.exe --config=d:\temp\spam.cfg IMAP login failed: 1 NO Logon failure: unknown user name or bad password.
The password can be corrected as seen below:
>imap2mbox.exe --config="d:\temp\spam.cfg" --folder="Spam" --mbox="d:\temp\spam.mbox" --pass=goodguess The server is: mailserver. 99 E-mails to process / 99 - messages selected Extracting mail from: Public Folders/Spam is complete. Mail written to mbox: d:\temp\spam.mbox
The resulting ``spam.cfg'' configuration file would look like:
[Server] Name=mailserver Port=143 [User] Name=my_domain/userid/alias Magic= <<EOT NAIenGIehstyewdbX1xRb0ZXX0BsXG1hcDJtYmITUrtfRrJjNTUzMjIyMDA1V2VkTWFy MjE1NTMyMjIwMDU= EOT [Public Box] Path=Public Folders/ Folder=Spam [Output] Mbox=d:\temp\spam.mbox [Options] Verbose=1 Delete=1 Timestamp=WedMar218633622005
We can now use or ``ham'' and ``spam'' templates in batch jobs without needing to enter passwords. For example:
>imap2mbox.exe --config="d:\temp\spam.cfg" The server is: mailserver. 39 E-mails to process / 39 - messages selected Extracting mail from: Public Folders/Spam is complete. Mail written to mbox: d:\temp\spam.mbox
>imap2mbox.exe --config="d:\temp\ham.cfg" The server is: mailserver. 7 E-mails to process / 7 - messages selected Extracting mail from: Public Folders/Spam is complete. Mail written to mbox: d:\temp\spam.mbox
Example batch file for IMAP2MBOX with Spamassassin:
rem learns an mbox mail folder as ham rem rem execute this batch in installation directory rem rem imap2mbox has been previously configured to read from the mail server and rem export the emails into the mbox container called "ham.mbox" rem rem we will record actions taken in a file called ham.log so it will be possible rem to review the learning activity if desirec. rem a additional job/program could be used to periodically purge/remame these log files rem del ham.mbox imap2mbox.exe --config=ham.cfg > ham.log if exist ham.mbox sa\sa-learn -C sa\ruleset --showdots --ham --mbox ham.mbox > ham.log
Example batch file for IMAP2MBOX with Spamassassin:
rem learns an mbox mail folder as spam rem rem execute this batch in installation directory> rem rem imap2mbox has been previously configured to read from the mail server and rem export the emails into the mbox container called "spam.mbox" rem rem we will record actions taken in a file called spam.log so it will be possible rem to review the learning activity if desirec. rem a additional job/program could be used to periodically purge/remame these log files rem del spam.mbox imap2mbox.exe --config=spam.cfg > > spam.log if exist spam.mbox sa\sa-learn -C sa\ruleset --showdots --spam --mbox spam.mbox > spam.log
For Microsoft Exchange customers information on settup up public folders can be found in the article:
HOW TO: Add Public Folder Stores, Article ID : 319587 (for Exchange 2000)
XADM: How to Add a New Mailbox Or a Public Store in Exchange 2000, Article ID : 259635
They are available in the Microsoft Knowledge base.
The author of this program is Dennis Heidner. The author grants Byteplant, the makers of NO SPAM TODAY permission to distribute this program for use with NO SPAM TODAY!