Email Price Checker – Part 1: Initial Setup

This post will walk through a complete project from start to scratch. Previously I’d created a small Selenium price checking test which runs great, but means that my pc has to run the app and no one can use it except me. This new project will build on that but receive an email, check the prices (slowly) and return an email with the cheapest codes back to the sender – that way I can use it from work 😉

For this app, I’m using Mule IDE, Java 1.6+, a Ubunutu server to run the application once written and an email address dedicated to listening for the price checking requests.

Lets get started!

To start with, we need a new project. This is using 3.3.2 of Mule because that’s the version I’d downloaded during the Mule training course. There is a newer version available, but it’s not necessary for now.


I tend to always use Maven as it makes it a lot easier to pull in dependencies.


So, once the projects been setup, we get the visual flow page ready to start building the application.


At this point it might be worth explaining what I want to achieve…
I need the application to:

  • Read emails from an email account.
  • Check they originate from a specific set of addresses to filter out rubbish.
  • Check they contain a code for the website we will be checking prices on (CPC).
  • Delay the message if there is already one in progress in order to prevent us being banned on the CPC website.
  • Each code contains 100 price sub codes – check the prices one at a time and delay between each sub code to prevent being banned.
  • Return the lowest codes and the price ex+inc vat to the sender.

First we need an email endpoint and connector for both sending and receiving of emails. I’m using POP3, but you could use IMAP. Additionally the body of the email will only contain the code needed to price check, so the email to string transformer has been chosen.



Or in code terms, that looks like:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:context="" xmlns:pop3s=""
	xmlns:smtp="" xmlns:email=""
	xmlns:pop3="" xmlns=""
	xmlns:spring="" version="EE-3.3.2"

	<pop3s:connector name="Pop3sConnector" doc:name="POP3"/>

    <context:property-placeholder location=""/>

	<flow name="PriceCheckerFlow1" doc:name="PriceCheckerFlow1">
		<pop3s:inbound-endpoint host="${}"
			port="${email.port}" user="${email.account}" password="${email.password}"
			responseTimeout="240000" connector-ref="Pop3sConnector" doc:name="POP3"/>
        <logger message="Message Received: #[message.payload]" level="DEBUG" doc:name="Logger"/>

And the properties file mentioned contains the following:


At this point, I’m going to test what I have by adding a logger to see what the payload is before I continue.


Run the application by right clicking on the project –> Run As –> Mule Application.

At this point I spent the next 8 hours or more tearing my hair out as I could not get anything to connect to my email account… After installing 5 different Comodo SSL certificates and the one for my web hosting, I still couldn’t connect. These are some useful settings for anyone in the same position:


When I looked very carefully at the certificates being checked, I found that avast! (antivirus) was interfering with the certificate hashes meaning the connection wouldn’t authenticate!

When eventually you do get it communicating with your email box, having sent an email to the box…


…you’d see something like this in the logs: