server not sending emails?

$> netstat -tanl|grep :25

should output

tcp 0 0* LISTEN
tcp 0 0 ::1:25 :::* LISTEN
test php mail
Put Php into interactive mode

$> php -a
$> mail(‘’, ‘subject’, ‘content’);

Is mail daemon running?


$>postfix stop && postfix start


Magento: How to get current url

$currentUrl = Mage::helper('core/url')->getCurrentUrl();

For example:

homepage = http://local.mag17/
product page = http://local.mag17/index.php/sony-vaio-vgn-txn27n-b-11-1-notebook-pc.html

ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint

As part of testing Magento’s order workflow I needed to truncate the sales tables.

However, Mysql complained with the following error:
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint

However, by switching of foreign key check, I was able to truncate the table.

TRUNCATE table1;
TRUNCATE table2;


MySql dump only tables with partial name

mysqldump -u <username> <database> $(mysql -u<username> -D <database> -Bse “show tables like ‘sales%'”) > <dumpfile.sql>

Javascript redirect on page load using prototypejs

First option using href

Event.observe(window, ‘load’, function() {
window.location.href = “;;

However a better way is to use replace method.

Event.observe(window, ‘load’, function() {

“because replace() does not put the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.”

Tagged ,

Retrieve the number of tables in a mysql database

To find out the number of tables in a particular mysql database, you can use the following sql statement.

SELECT count(*) from information_schema.tables WHERE table_schema = 'dbname';