Log4j comes with an appender that will send an email when a logging event occurs. The appender class is org.apache.log4j.net.SMTPAppender and the following gives an example of its configuration
<appender name="LogEmail" class="org.apache.log4j.net.SMTPAppender">
<param name="BufferSize" value="512" />
<param name="SMTPHost" value="mail.server.com" />
<param name="From" value="email@example.com" />
<param name="To" value="firstname.lastname@example.org" />
<param name="Subject" value="Log from myapp" />
value="%p %t %c - %m%n" />
If you’re having trouble getting your iphone to connect to your plesk mail server then it may be due to limited imap connections being available.
By default a plesk server only allows a maximum of 4 IMAP connections from the one IP. If you have a few computers behind a router then these can quickly get used up. Once users start trying to also connect with iphones the problem quickly gets worse.
To fix the maximum number of connections needs to be uincreased. The configuration file that needs to be changed is:
And the setting that needs to be changed is:
Try increasing it to say 10 or 20, or whatever is appropriate in your environment.
For sites with lots of users the MAXDAEMONS setting may also need to be increased.
Once that is changed you just need to restart the imap service.
sudo /etc/init.d/courier-imap restart
Use JavaMail API
// Create session
Properties sessionProperties = System.getProperties();
Session session =
// Create message
Message message = new MimeMessage(session);
// Send the message