How to configure POP-based Fetchmail for JBoss Mail Server 1.0M3
versions: 1.0M3, 1.0M4
Often users want mail to be forwarded from another mail server for various reasons but are unable to have that mail server push the mail to them. One solution to this is to configure the mail server to retrieve the mail as if it were a client of the other server. It retrieves the user's mail on that user's behalf and puts the mails into the user's local mailbox on the local mail server.
Define the "Popper" block
For EACH user/server you want to "fetchmail" for you must define a block like this one:
<mbean code="org.jboss.mail.fetchmail.Popper" name="jboss.mail:type=Fetchmail,name=Popper"> <attribute name="Servername">foo.nowhere.com</attribute> <attribute name="PopPort">110</attribute> <attribute name="PopUser">remoteuser</attribute> <attribute name="Password">mypassword</attribute> <attribute name="LocalUser">andy@localhost</attribute> <attribute name="DeleteAfterPop">false</attribute> <depends optional-attribute-name="SMTPProtocol" proxy-type="org.jboss.mail.smtp.SMTPProtocolMBean">jboss.mail:type=MailServices,name=SMTPProtocol</depends> </mbean>
This example means that all mail for the user "remoteuser" will be retrieved from the "foo.nowhere.com" mail server which operates the POP service on port 110. The mails will be put in the local mail server (apparently called localhost) for user "andy@localhost" where "localhost" must be a domain in that server's LocalDomainGroups list.
The DeleteAfterPop option specifies whether the messages will be removed from the remote server once they have been retreived and placed on the local server.
Each instance that you define must have a unique name. A suggested naming pattern might be:
Triggering the fetch
This block itself only defines a service for pop fetchmail. It doesn't define when it should be triggered. You can manually trigger it by launching the JMXConsole of JBAS, finding it by its MBean name and clicking on the "pop" operation. However this wouldn't be very convienient. Its best if it happens at an interval, say every 10 minutes. For this JBAS provides the Scheduler.
Add this additional block:
<mbean code="org.jboss.varia.scheduler.Scheduler" name="jboss.mail:service=Scheduler,name=Popper> <attribute name="StartAtStartup">true</attribute> <!-- this needs to match your Popper instance's mbean name --> <attribute name="SchedulableMBean">jboss.mail:type=Fetchmail,name=Popper</attribute> <attribute name="SchedulableMBeanMethod">pop()</attribute> <attribute name="InitialStartDate">NOW</attribute> <attribute name="SchedulePeriod">10000</attribute> <attribute name="InitialRepetitions">-1</attribute> </mbean>
The above would trigger the pop fetchmail service every 10 minutes using the Popper config block we previously defined. it would start "now" (after you restart JBMS) and run continuously.