Hi Benjamin

you can write simple mailet [java class] extending GenericMailet & inside
that you can connect to DB [simple JDBC].

public class ValidateMails extends GenericMailet {

protected String dbDriver;
    protected String dbURL;
    protected String dbUser;
    protected String dbPass;


    public ValidateMails() {
    }

    @Override
    public void init(MailetConfig newConfig) throws MessagingException {
        super.init(newConfig);
    }

    @Override
    public void service(Mail mail) throws MessagingException {

// Connect to DB do your validation
Connection conn = getDBConnection();
// Validation goes here
}

protected Connection getDBConnection() {
        Connection conn = null;
        try {
            Class.forName(dbDriver);
            conn = DriverManager.getConnection(dbURL, dbUser, dbPass);
        } catch (Exception e) {
            log("Exception Stack trace = ", e);
        }
        if (conn == null) {
            log("Unable to get DB connection ...");
        }
        return conn;
    }
}

Edit Config.xml & add following mailet inside root processor

 <mailet
                match= "HostIsLocal"
                class= "ValidateMails">

                <driver>oracle.jdbc.OracleDriver</driver>
                <dburl>jdbc:DBURL-GOES-HERE</dburl>
                <user>USERNAME</user>
                <pass>PASSWORD</pass>
    </mailet>

On Wed, Apr 27, 2016 at 12:15 PM, Benjamin Yeo <ro4drun...@gmail.com> wrote:

> Hi guys, sorry to post again but can someone please give me an example of a
> simple matcher
>
> For example, my matcher will just connect to database, then retrieve
> records in the database. That is all. I do not need anything else. Can
> someone please help me on this because I am stuck in at this for a long
> long time.
>
> Thanks
>



-- 
Thanks
Muhammad Ismail
cell (PAK) : +92.322.5100362
cell (Sweden): +46 700-321-521
e-mail: it.is.ism...@gmail.com

This message may contain confidential and/or privileged information.  If
you are not the addressee or authorized to receive this for the addressee,
you must not use, copy, disclose or take any action based on this message
or any information herein.  If you have received this message in error,
please advise the sender immediately by reply e-mail and delete this
message.  Thank you for your cooperation.

Reply via email to