Disable Outgoing Mail in Drupal 7

* Implements hook_mail_alter
function yourmodule_mail_alter(&$message) {
// set ‘To’ field to nothing, so Drupal won’t have any address
$message[‘to’] = ‘ ‘;

Other Way you can do

If using devel with drupal 6, add to settings.php
$conf[‘smtp_library’] = ‘sites/all/modules/devel/devel.module’;

and all outgoing emails get logged in watchdog.

If using devel with in drupal 7, if you add
$conf[‘mail_system’] = array(‘default-system’ => ‘DevelMailLog’);

emails get written to files in the drupal temporary directory.

Re-route All Emails Using Reroute Email Module

Download and install the Reroute Email module.

Go to Configuration-> Reroute Email (admin/config/development/reroute_email).

And  than Check the Enable rerouting checkbox and enter in an email address into the Email addresses text field.




Steps to follow for query tuning

Few steps for query tuning.

1)  Check for if any sub query or exists or not exists is there if yes then try to change it in the joins .

2)  Try to check the way joins had been written try to put it in format to follow one to many relation ship and joins are in primary to foreign keys.

3)  if dead locks are happening due try to implement the serialization or try to use hint with (nolock) with select statement and with (rowlock) with insert update and delete statement.

There are many more way to do.

File system and mysql backup on shared hosting

Create two php files and upload to server. Following script will compress your files and able to take mysql backup in gzip format.

Before this create phpinfo.php file and add following code.




$Command = 'tar -czf /public_html/content/html/website.tgz /public_html/content/html';
exec($Command, $output, $result);
if($result > 0) {
echo 'Command not executed. ';
echo 'Error Details:'.$output;
} else {
echo 'Command executed sucesfully.';

create mysqlbackup.php  file and add following lines.

$Command = 'mysqldump -udbusername -pdbpassword -hyour_database_hostname DBname | gzip > DBname.gz';

exec($Command, $output, $result);
if($result > 0) {
echo 'Command not executed. ';
echo 'Error Details:'.$output;
} else {
echo 'Command executed sucesfully.';


Install Drupal using Drush command only

For setup the empty drupal project setup use following command

#drush dl drupal-7
Project drupal (7.28) downloaded to /home/manish/drupal-7.28.                                                                                                       [success]
Project drupal contains:                                                                                                                                           [success]
– 3 profiles: testing, minimal, standard
– 4 themes: stark, seven, bartik, garland
– 47 modules: drupal_system_listing_incompatible_test, drupal_system_listing_compatible_test, poll, rdf, statistics, user, taxonomy, translation, tracker, node,
contact, syslog, contextual, profile, overlay, forum, blog, book, system, aggregator, path, comment, help, simpletest, trigger, menu, dashboard, search, locale,
field_ui, shortcut, options, number, field_sql_storage, text, list, field, php, color, toolbar, filter, update, dblog, file, block, image, openid

#cd drupal-7.28

#drush site-install standard –account-name=admin –account-pass=admin –db-url=mysql://mydbusername:’pass@123’@localhost/mydbname

You are about to create a sites/default/files directory and create a sites/default/settings.php file and DROP all tables in your ‘marketplace’ database. Do you want to continue? (y/n): y
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1
Starting Drupal installation. This takes a few seconds …                                                                                                         [ok]
Installation complete.  User name: admin  User password: admin

after this you can check project in browser.


Redirect all traffic to HTTPS on your Drupal site

Your Drupal .HTACCESS file should now have a section that looks similar to this : – # Various rewrite rules. <IfModule mod_rewrite.c>   RewriteEngine on # Set “protossl” to “s” if we were accessed via https://.  This is used later # if you enable “www.” stripping or enforcement, in order to ensure that # you don’t bounce between http and https.   RewriteRule ^ – [E=protossl]   RewriteCond %{HTTPS} on   RewriteRule ^ – [E=protossl:s]