Wednesday, October 23, 2013

OpenEMM Mail Server Configuration In Unix

After spent lot of time on internet for the mail server configuration on OpenEMM, I found no best approach to follow required steps.

Not to dig-in much. Here I am describing some steps to be followed.

The use of Sendmail is enabled by default in OpenEMM. This should be disabled first.
But before that if your server is running then first stop the same.

1. Change to user openemm with
su - openemm

2. Go to /openemm/bin directory and stop the server
sh openemm.sh stop

3. Disable Sendmail with in the same directory with following command
sh sendmail-disable.sh

4. Go to /openemm/conf directory

5. Create a file with name smart-realy and add content inside that as below.
username:password@smtp.mytestserver.com

6. If your username or password contains "@" special character then you need to modify semu.py file in /openemm/bin/scripts directory.

Just open the file with a text editor and replace character @
with the pipe symbol | in lines 160 and 163 each.

7. Start the server with following command. Go to /openemm/bin directory
sh openemm.sh start

This is it.

Hope this will help you for the configuration to the point.




Tuesday, October 22, 2013

Google Cloud SQL Integration with Google App Engine


One of App Engine’s most requested features has been a simple way to develop traditional database-driven applications. In response to the feedback, google announced the
Google Cloud SQL. There are several advantages after using Google Cloud SQL over other database. Google Cloud SQL brings many benefits to the App Engine community:
  • No maintenance or administration
  • High reliability and availability
  • Familiar MySQL database environment with JDBC support (for Java-based App Engine applications) and DB-API support (for Python-based App Engine applications).
  • Comprehensive user interface for administering databases.
  • Integrated with Google App Engine and other Google services
  • Simple and powerful integration with Google App Engine.
Google Cloud SQL allows you to create, configure, and use MySQL databases that live in Google's cloud. It is a fully-managed service that maintains, manages, and administers your databases. It is primarily intended for programmatic use within applications. It has an interactive UI, which is helpful for learning about the product, getting started using it, investigating the schema, and submitting trial queries.
To setup Google Cloud Storage in your GAE application using JDBC, follow the below mentioned 3 steps:
·         Create a Google Cloud SQL Instance from.
·         Configure the Google Cloud SQL Instance from
·         Connect the Google Cloud SQL Instance
Cloud SQL Data Creation and Ingestion
Google Cloud SQL lets you import existing databases or create them from scratch. You can perform the usual SQL commands to create and drop database tables, and to create, update, and delete rows and data as follows:
·         interactively from the online SQL prompt
·         from the command line with the google_sql tool
·         from App Engine applications
·         programmatically from other applications using JDBC
·         from Apps Script scripts
·         using third-party tools, such as the Squirrel SQL Client
To create and configure an SQL instance you can follow instructions from here and here.

Connect the Google Cloud Instance

To connect to the Google cloud instance, follow the below mentioned guidelines:

/**
    * Method to retrieve the database connection
    *
    * @return
    */    
   public Connection getConnection() {
         String url = null;
         Connection connection = null;
         try {
               if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
                     logger.info("Trying to establish connection");
                     Class.forName("com.google.cloud.sql.jdbc.Driver");
                     url = "jdbc:google:rdbms://reservosdevbatch:rvdevbatchdb/email_campaign?user=root";
               } else {
                     // Local MySQL instance to use during development.
                     Class.forName("com.mysql.jdbc.Driver");
                     url = "jdbc:mysql://localhost:3306/email_campaign?user=root&password=root";
               }
               connection = (Connection) DriverManager.getConnection(url);
         } catch (Exception e) {
               logger.info("Error while connecting");
               logger.info(e.getLocalizedMessage());
         }
         return connection;

   }
·         Add the MySQL Connector Jar
Manually put mysql-connector-java-5.1.22-bin.jar in your app engine sdk folder: file:///opt/appengine-java-sdk-1.6.0/lib/impl/

·         Enable MySQL Connector/J
The MySQL Connector/J is available in Google App Engine but it's not included in an app unless the app explicitly asks for it. To do that, add a <use-google-connector-j> element to the app's appengine-web.xml file as shown in the following example:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">

      ...

      <use-google-connector-j>true</use-google-connector-j>
  
   ...

</appengine-web-app>


Happy Clouding!!
That's it! Now you can deploy your application and try it out!