Thursday, May 22, 2014

Process bounced messages through BoogieTools in JAVA

Here is a sample JAVA code to process bounced messages in a mail server through BoogieTools API.
You need to have the BounceStudio so files in your class path while executing the code.

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import javax.mail.Flags;
import javax.mail.Flags.Flag;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;


import com.boogietools.bouncestudio.BounceStudio;
import com.boogietools.bouncestudio.BounceStudio.BounceResult;
import com.sun.mail.imap.IMAPMessage;

public class BoogieToolsBounceProcessor
    private static final Map<Integer, String> BOUNCE_CODES_MAP;

        Map<Integer, String> aMap = new HashMap<Integer, String>();
        aMap.put(10, "HARD_BOUNCE_USER_UNKNOWN");// "HARD BOUNCE - (ie. User Unknown)");
        aMap.put(20, "SOFT_BOUNCE_OTHER");// "SOFT BOUNCE - General");
        aMap.put(21, "SOFT_BOUNCE_DOMAIN_FAILURE");// "SOFT BOUNCE - Dns Failure");
        aMap.put(22, "SOFT_BOUNCE_MAILBOX_FULL");// "SOFT BOUNCE - Mailbox Full");
        aMap.put(23, "SOFT_BOUNCE_MESSAGE_TOO_LARGE");// "SOFT BOUNCE - Message Too Large");
        aMap.put(40, "UNKNOWN_BOUNCE_UNKNOWN");// "GENERAL BOUNCE");
        aMap.put(50, "BLOCK BOUNCE - BLOCKED");// "MAIL BLOCK - General");
        aMap.put(51, "BLOCK_BOUNCE_KNOWN_SPAMMER");// "MAIL BLOCK - Known Spammer");
        aMap.put(52, "BLOCK BOUNCE - SPAMBLOCKED");// "MAIL BLOCK - Spam Detected");
        aMap.put(53, "BLOCK_BOUNCE_CONTENT");// "MAIL BLOCK - Attachment Detected");
        aMap.put(54, "BLOCK_BOUNCE_RELAY_DENIED");// "MAIL BLOCK - Relay Denied");
        BOUNCE_CODES_MAP = Collections.unmodifiableMap(aMap);

    public static void main(String[] args)
        boolean isDebug = false;
        if (args.length < 2) {
            System.out.println("Usage: BoogieToolsTest <mail_host> <mail_user> <mail_password>");

            String host = args[0];
            String user = args[1];
            String password = args[2];
            System.out.println("Processing bounced messages in "+host);
            Properties props = System.getProperties();
            props.setProperty("", "imap");
            Session session = Session.getDefaultInstance(props, null);
            Store store = session.getStore("imap");
            store.connect(host, user, password);
            Folder inbox = store.getFolder("Inbox");
            int unreadCount = inbox.getUnreadMessageCount();
            System.out.println("There are "+unreadCount+" to be processed");
            Message[] messages = FlagTerm(new Flags(Flag.SEEN), false));
            for (Message message : messages) {
                String bounceReasonCode = getBounceReason(message);
                if (bounceReasonCode != null)
                    System.out.println("Bounce Code: "+ bounceReasonCode);
                    //Do something
        }catch(Exception e){}
        System.out.println("Finished processing bounced messages");
    private static String getBounceReason(Message message)
            String messageText = IOUtils.toString(message.getInputStream());
            System.out.println("Going to make Boogietools call");
            BounceResult bresult = BounceStudio
                        .bounceCheck(messageText, "",
            System.out.println("Return from Boogietools: "
                      + bresult.getResult());
            return BOUNCE_CODES_MAP.get(bresult.getResult());
        catch (IOException e)
        catch (MessagingException e)

        return null;

Tuesday, August 20, 2013

Old Nalukettu in Kerala

Here is a 360-degree view of one side of an old 'Nalukettu' near Poovar, Trivandrum, Kerala. This place has become location for a movie and many short-films and tele-serials.

Wednesday, March 27, 2013

Estuary Island Poovar

Had a visit to Estuary Island Resort & Hotel, at Poovar, near to Kovalam. This is a beach resort. They provide good ambiance, food and entertainment facilities.

The nearest airport is Trivandrum. This place is around 30 km from Thiruvananthapuram. This resort is located at the place called Poovar.

From Poovar you can reach Estuary Island Resorts via boat or via road. The place is a nice one with good greenery and an open stage (if you like to do some cultural events).

The website of the resort is :

Monday, December 31, 2012

Places near Kanyakumari - Part 1 - Kattadi Malai

Kattadi malai is famous as the place where Blessed Devasahayam Pillai was shot dead. This is in the Aralvaimozhi panchayat town of Kanyakumari. The place is well maintained by the church authorities with sculptures of Jesus' crucifixion. The place where Devasahayam Pillai's body was found, the place with prints of Devasahayam Pillai's knees and elbows, bell-rock etc are maintained here. There is also a set of marble carvings on the last days of Devasahayam Pillai.


Video showing a part of Bell-Rock (maniyadichan parai), the rock which makes bell-like sound when knocked with a stone.

Wednesday, December 26, 2012

My first 3D building

The first 3D building that I modeled through google's sketchup tool is CSI Church Peringammala. It was complex one and I did skip the stairs to the top while creating the 3D model.

Monday, November 26, 2012

Gavi - Solitude limited

Very often we get irritated when the increasing number of tourists pollutes an eco friendly place with noise and plastic. But Gavi does not come under that kind of places and is an excellent spot for those who love trekking and solitude. You will have the pleasure of boating and trekking inside the periyar tiger reserve forest.

You can contact Thekkady tourism department to get the details (Phone: 04869-222620). Even you can travel direct to Gavi, but sometimes they restricts the number of vehicles to Gavi.


  In the following photograph you could see a distant image of the Sabarimala temple. A few people come to this place and see the makara jyothi.