views:

458

answers:

3

Hi, I want to set up a program where all incoming emails into vpopmail of the form [email protected] get forwarded to a java program / daemon that is running the java program will receive the information about the person sending the email so it needs to access the standard email and from the account (in the above case 12345678) infer where to send it on. then once it has received a confirmation code from the daemon, delete the email

I'm using a qmail / vpopmail combination on linux (debian), so I'd rather that fire an event to my java daemon than poll the mail accounts, through the java mail extensions.

Any help is greatly appreciated

+1  A: 

Look into procmail and formail -- see the procmailex manual page and the procmail-lib package on Debian.

Dirk Eddelbuettel
+1  A: 

I'm using a qmail / vpopmail combination on linux (debian), so I'd rather that fire an event to my java daemon than poll the mail accounts, through the java mail extensions.

This sentence implies that you must use IMAP/POP3 access to poll a mail account. If your java app is on the same host as the mail server, it could also poll a Maildir directory directly by looking for new files in the path_to_maildir_folder/new directory.

Maildir on wikipedia

Trevor Harrison
+1  A: 

Use procmail if it is installed on your system. Put these lines in a .procmailrc file in the home directory of the user who receives the e-mail.

:0
| /path/to/your/program

Or you can instead use a .forward file containing

"|/path/to/your/program"

Procmail has the advantage that it allows you to deal with more complicated filtering if your application ever requires it.

Your program will read the headers and body of the e-mail from stdin.

bmb