incoming emails
Hi,
I am new to java mail. I would like to create an application which reacts to incoming emails. It will parse information from the email and eventually send back a reply email. I think I will be ok for the parsing and reply but I am not sure where to start on having an incoming email trigger my java code. I would like this to happen as soon as the email arrives -- not have java code check for new emails every 5 minutes.
any help is appreciated. i have done some searching and did not see much.
-Joe
# 1
There's three major choices:
1. You can use a server-specific method to cause your SMTP server to call your
program when a message arrives. For example, sendmail can be configured
to do this. Usually you'll get the message text passed to you as a parameter
or as input. You can use the MimeMessage constructor that takes an
InputStream to parse the message.
2. If you're using IMAP, you can use the experimental feature I added to the latest
test version of JavaMail that allows you to use the IMAP IDLE command. This
command allows the server to notify you as soon as a message arrives in a mailbox.
It depends on the server supporting the IDLE extension.
3. You can poll a mailbox for new messages, using POP3 or IMAP.