Archive for the ‘Development Tutorials’ Category

Connect Joomla to an SMTP Server

Monday, November 5th, 2012 by rtssys

Connecting Joomla to an SMTP can be difficult with a fresh install on a new server.  Detailed are many steps which may or may not impact your particular environment but are all worth trying to resolve any issues you may be having.

These steps are detailing a Joomla 1.5.17 install onto a dedicated Centos 6.3 linux web server connecting to a Microsoft Exchange Server to send SMTP email.

You may have to use sudo or sudo -u root depending on how your server is setup to execute many of these commands.


Is sendmail installed?  Is it the latest version?

  • Get sendmail installed


Check what version of Sendmail is installed on your box

 rpm –qa sendmail

Update to the most recent version.

 sudo yum install sendmail

You may also need this to create your cf file

sudo  yum install sendmail-cf

  • Get sendmail running

You may have to shut down postfix because you can’t have sendmail and postfix running at the same time

sudo  /etc/rc.d/init.d/postfix stop

Or

sudo service postfix stop

Next you should make sure that the sendmail service is running

sudo service sendmail restart

Then check it’s status

sudo service sendmail status

You want to see something like this:

sendmail (pid  15687) is running…
sm-client (pid  15696) is running…

sendmail (pid  15687) is running…

sm-client (pid  15696) is running…


Make sure sendmail starts up if your restart your box

sudo chkconfig sendmail on

Are your Configuration Settings Correct?


  • /etc/mail/sendmail.mc

Replace this line in sendmail.mc

DAEMON_OPTIONS(`Port=smtp, Addr=127.0.0.1 Name=MTA’)dnl

with

DAEMON_OPTIONS(`Port=smtp, Name=MTA’)dnl

You may have to define this host as well:

define(`SMART_HOST', `yourSMTPserverDomain')dnl

Save the file and restart sendmail again

Can Httpd send emails?

Check your email settings here:

getsebool -a | grep mail

if httpd_can_sendmail is off then you will have to run this command to turn it on.  It will take a minute so just wait.


sudo -u root setsebool -P httpd_can_sendmail on

Restart sendmail again and make sure it’s running.

  • Try sending a test email:

/usr/sbin/sendmail youremail@gmail.com

-> Press Enter

Type:  ”Subject: test”

-> Press Enter

Type ‘.’

-> Then press enter again

Setup you Server in the Joomla back end Admin Console

Site -> Global Configuration -> Server

  • Try sending a test email through the  Joomla back end admin console:

Then you can send a test email using:  Tools -> Mass Mail.

Other problems?

Having trouble finding files?

Use this command to find files:

find / -name 'filename'

If you have any other problems check the mail logs:

sudo tail -f /var/log/maillog
Please let me know if I left out anything and I hope this helps any problems you may have!

Having trouble with the Grails install-plugin command?

Thursday, October 27th, 2011 by rtssys

Are you having issues with dependencies or other problems when trying to use install-plugin?

We are using:

Grails 1.3.7

STS 2.5

Go into your project’s BuildConfig.groovy

/[Your_Project_Name]/grails-app/conf/BuildConfig.groovy

Find the repositiories section:

repositories { grailsPlugins() grailsHome() grailsCentral()

// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenLocal()
mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"

}

Search for mavenCentral().
Uncomment this line out. This will then enable remote dependency resolution.

Then try the install-plugin command on the command line.

Here is an example:

install-plugin mail

or

install-plugin http://plugins.grails.org/grails-mail/tags/RELEASE_1_0-SNAPSHOT/grails-mail-1.0-SNAPSHOT.zip 

If running install-plugin on the command line does not work for you, you can try the plugin manager.

Right-click your project -> Grails Tools(Towards the bottom) -> Grails Plugin Manager.

Search for your plugin then install and click the OK button.

http://stackoverflow.com/questions/7905714/grails-install-plugin-does-not-work-for-me/7921928#7921928

Groovy: “That’s 357 Minutes Of My Life I Can’t Get Back”

Friday, July 29th, 2011 by jyot

So there I was. I worked my full day of client meetings and looking for new office space, only to face a late-night data migration, transferring data between two tables.  I did not expect it to be an overnight endeavor.

The Groovy script I had authored seemed simple and straightforward to me.  I logged in, cd’d to its location on the server, typed the name of the script, and hit enter.


Six hours later, the prompt returned.


You can imagine I was not a happy camper, constantly executing queries on the database to answer the question: “Is it really doing anything? Is it hung?”
Row by row the data was deposited.  Six long hours later, I wearily logged off and crawled into bed just as the sun began to peek over the horizon.
I did not want to repeat this. 
So, I did a little research.  Hopefully what I learned can help others avoid this very costly oversight.

Enter Groovy’s  batchUpdate feature.  Perhaps I’m just a little late to this party, but from a novice’s perspective, Approach 1 (see listing) seems perfectly reasonable: for each row in one table, insert the data into another table.



Approach 1: “Brute Force”


// This took more than 6 Hours

mssql.withTransaction

{

cachesql.eachRow(”select * from HDL.TransactionJournal where TransactionDate between ‘2010-08-01′ and ‘2011-08-01′ “)

{ row ->

mssql.execute(”insert into[dbo].TransactionJournal (ID, TransactionDate,TxCode,TxType) values (?,?,?,?)”, [row.ID,row.TransactionDate, row.TxCode,row.TxType])

}

}




After running this script and painstakingly monitoring its progress overnight, I embarked on a quest to determine the better way to do this.  After a bit of searching, I discovered Groovy’s batchUpdate. 

I quickly rewrote my script, and the same data transfer took 3 minutes.  That’s right – from 360 minutes to 3.  How’s that for two orders of magnitude’s difference?

The concept is this: do a mass insert, and commit every x number of rows, instead of inserting and committing each row singly.  The higher you set the parameter for committing, the faster it will run.

Approach 2: Same Data Shuffling, Much Faster Performance

// This took 3 mins

mssql.withTransaction

{

//it commits after each 10K insert

def updateCounts = mssql.withBatch(10000, “insert into[dbo].TransactionJournal (ID,TransactionDate,TxCode,TxType) values (?,?,?,?)”,

[row.ID,,row.TransactionDate, row.TxCode,row.TxType]“)

{ ps ->

cachesql.eachRow(”select * from dbo.TransactionJournal where TransactionDate between ‘2010-08-01′ and ‘2011-08-01′ “)

{ row ->

ps.addBatch([row.ID,row.TransactionDate, row.TxCode, row.TxType])

}

}

}

The underlying lesson learned here is a fairly standard one, which is, when doing something that looks like batch processing in a database, make sure to use batch processing (within a transaction) to ensure optimal performance. 

Groovy’s batch processing feature was introduced in November 2010 with the release of 1.7, so anyone who picked up Groovy prior to that (like myself) may be accustomed to working around this previously missing feature.

Hopefully this article will help others avoid the mistake of quickly whipping up a script like this – only to sit and watch it execute, not-so-quickly.

Prevent users to accidently navigate away and lose data – GWT/SmartGWT

Friday, June 10th, 2011 by jyot

Just add to the panel. A very useful code.

//Added the code to prevent the users navigating away.
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
closingEvent.setMessage(”Do you really want to leave the page?”);
}
});

//Added the code to prevent the users navigating away.

Window.addWindowClosingHandler(new Window.ClosingHandler() {

public void onWindowClosing(Window.ClosingEvent closingEvent) {

closingEvent.setMessage(”Do you really want to leave the page?”);

}

});

Setting up a SQL Server 2008 R2 Local Database Instance

Tuesday, May 24th, 2011 by rtssys

Setting up and accessing a local database instance in SQL Server 2008 is a somewhat less then intuitive process.  This post will attempt to alleviate some of the wasted time and frustration of this process.  Please let me know if you experience any issues and also if you see anything that needs to be corrected.  Thanks and I hope this helps!

Start up the Local Server

  • Click Start -> Microsoft SQL Server 2008 R2 -> SQL Server Configuration Manager
  • Set the SQL Server(SQLEXPRESS) and SQL Server Browser to automatic start mode.
  • Right click -> Properties -> Service Tab
SQL Server 2008 Server Settings

SQL Server 2008 Server Settings

Login to Local Server

  • Now open up SQL Server Management Studio and Connect to Object Explorer and select Server Name: [Your PC name]\SQLEXPRESS
  • Example:  8540P-KL\SQLEXPRESS
  • To find your PC name:  Right click My Computer -> Properties -> Computer Name tab
  • Login using windows authentication:  Using the user name [Your Domain]/[Your User Name]
SQL Server 2008 Login Settings

SQL Server 2008 Login Settings

Setup User Account

  • In SQL Mgmt Studio -> Expand your local Server -> Security -> Right click on Logins -> New Login
  • Uncheck Enforce password policy, password expiration and user must change pw(Since this is local)
  • Default database -> Your Database
  • User Mapping Page -> Map to your db and grant db_owner role
  • Status Page -> Grant Permission to connect and Enable Login
SQL Server 2008 User Settings Local DB

SQL Server 2008 User Settings Local DB

Setup Access Permissions/Settings for User

  • Right click your Local Server -> Properties -> Security Tab -> Enable SQL Server and Windows Authentication Mode
  • Open SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for SQLEXPRESS -> Enable TCP/IP
SQL Server 2008 Server Permissions

SQL Server 2008 Server Permissions

Database Properties File for Spring Project

  • database.url=jdbc:jtds:sqlserver://[local PC Computer name];instance=SQLEXPRESS;DatabaseName=[db name];
  • database.username=[Your user name]
  • database.password=[Your password]
  • database.driverClassName=net.sourceforge.jtds.jdbc.Driver

Thank you and feel free to post any additional questions below.

Chris Anatalio