Configure website to send E-mails using SMTP server/Gmail account

Configure website to send E-mails using SMTP server/Gmail account

Hi 🙂
we all are developing websites for ourself, college projects and clients and every website requires the ability to send e-mails on certain events like when a user wishes to contact you for more details on your work or is interested in your services.

It was bit dissicult to send e-mails in Classic ASP and 1.1 but since the release of 2.0 framework sending e-mails is very easy and faster.

Requirements for sending E-mail’s

  • A website (yes, the one you are developing or modifying)
  • A SMTP Server to send your mails out.
  • Username, password to authenticate yourself to SMTP server

public static void SendMail(string MailTo, string MailFrom, string Subject, String MailBody)
System.Net.Mail.MailMessage objMailMessage = new System.Net.Mail.MailMessage(
MailFrom, MailTo);
objMailMessage.Subject = Subject;
objMailMessage.IsBodyHtml = true;
objMailMessage.ReplyTo =new MailAddress("");
objMailMessage.Body = MailBody;
SmtpClient objsmtp = new SmtpClient();
objsmtp.EnableSsl = true; // this statement is required in case you are planning to use Gmail account/Google apps account

Next You need to use following function to send email to user or yourself. You just need to paas proper arguments and it will take care of rest.

After that place following code in your website’s web.config file.

<smtp from=””>
<network host=”” port=”587″ password=”email-password” userName=”” />

Default port for SMTP server is 25.
For Gmail/Google Apps accounts it is 587.
If above port numbers does not work for you, please ask you e-mail provider about the port number in use.


I hope you find this post useful.
Thank you for reading.

c/c++ pattern printing program using for/while loop

c/c++ pattern printing program using for/while loop

Write a program to print following pattern in C/C++.

int main()
for(int i=1;i<=5;i++)
for(int j=1; j<=i;j++)


//now print lower part of pattern
for(int i=4;i>0;i–)
for(int j=1; j<=i;j++)
return 0;


Difference between Java and C programming language

Difference between Java and C programming language

Java is an pure object oriented programming language, it uses the concepts of Classes, Objects, Inheritance, Polymorphism. And the execution of a program is non-linear.
It is so called because you can’t write a program with out using classes & objects.

  • Java’s motto (so to speak) is “write once run anywhere”.
  • When you compile a Java program, an intermediate bytecode is generated, which itself is interpreted by the Java Virtual Machine. This way you write a program once, and the virtual machine translates the bytecode into instructions a specific processor can understand.
  • Execution of a Java program is by consequence a bit slow, because the intermediate bytecode has to be interpreted.
  • Java uses a “Garbage Collector” which manages memory automatically so the programmer doesn’t have to handle that.
  • Variables in Java can be declared anywhere in a program. (Although it is recommended to declare/define them at the beginning of blocks).
  • Reuse of code achieved by inheritance.
  • By default members are private.
  • During the execution of bytecode by JVM, it does not substitute the entire classes of package which are imported in the program. It just enters the package and executes the class and returns result in to the program. Due to this less memory is used by java program.

C Programming Language

  • C uses concept of structures (not object oriented).
  • In C we use the concept of pointers whereas there are no pointers used in JAVA
  • In C the programmer needs to manage memory manually. “malloc()” and “free()” are the fundamental memory allocation library calls.
  • In C the declaration of variables should be on the beginning of the block.
  • C supports go to statement, struct and union unlike Java
  • C is compiled to the machines “native language” so it’s execution is much faster than Java’s.
  • No reuse in code and by default members are public.
  • C programs will have a larger memory footprint than an equivalent program written in pure machine code, but the total memory use of a C program is much smaller than the a Java program because C does not require the loading of an execution interpreter like the JVM.
  • The main differences between Java and C are speed, portability, and object-orientation.

Java was created for the purpose of making a language that could be implemented on many different types of computers (cell phone, mac, PC, linux, etc.) C on the other hand can only be run on a computer of the same type as the one that compiled the program.

Java is also object-oriented, whereas C is not. Java allows a user to create classes that contain data and methods. C is not capable of doing that.

Operating Systems important interview questions

Operating Systems important interview questions

These are the some of the important interview questions regarding operating systems

Explain the concept of semaphore?
A semaphore is a protected variable or abstract data type that provides a simple but useful abstraction for controlling access by multiple processes to a common resource in a parallel programming environment. Semaphore is a correct way which help operating system to share its source between processors

What is memory management?
Memory management is the act of managing computer memory. In its simpler forms, this involves providing ways to allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. The management of main memory is critical to the computer system.

What is virtual memory?
Virtual memory is a memory management technique developed for multitasking kernels. This technique virtualizes a computer architecture’s various hardware memory devices (such as RAM modules and disk storage drives), allowing a program to be designed as though:
there is only one hardware memory device and this “virtual” device acts like a RAM module.
The program has, by default, sole access to this virtual RAM module as the basis for a contiguous working memory (an address space).

What is paging, segmentation?
Primary memory is divided into small equal sized partitions (256, 512, 1K) called page frames.
Process are divided into same sized blocks called pages.
Only bring in the pages you are referencing and keep those you have recently referenced.
Need a page table to this management.
Paging suffers from internal fragmentation.

SegmentationSegmentation maps segments representing data structures, modules, etc. into variable partitions. Not all segments of a process again are loaded at a time, nor are they in contiguous memory blocks.

Internal and external fragmentation?
Fragmentation occurs in a dynamic memory allocation system when many of the free blocks are too small to satisfy any request.
External Fragmentation: External Fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used. If too much external fragmentation occurs, the amount of usable memory is drastically reduced. Total memory space exists to satisfy a request, but it is not contiguous.

Internal Fragmentation: Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks. Allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.

Another Definition:
Internal Fragmentation is the area in a region or a page that is not used by the job occupying that region or page. This space is unavailable for use by the system until that job is finished and the page or region is released.

What is O.S? (operating system)
An operating system (OS) is software, consisting of programs and data, that runs on computers, manages computer hardware resources, and provides common services for execution of various application software.

Functions of O.S?
Main functions of an Operating System are:

  • – Resource Management,
  • – Data Management,
  • – Job (task) Management, and
  • – Standard means of communication between user and computer.

What is TLB or TLAB?
A translation lookaside buffer (TLB) is a CPU cache that memory management hardware uses to improve virtual address translation speed. All current desktop and server processors (such as x86) use a TLB to map virtual and physical address spaces, and it is ubiquitous in any hardware which utilizes virtual memory.

Multiprogramming, Multitasking, Multiprocessing?
The term Multitasking is used when more than one applications/programs/tasks are being run on a single processor. On the other hand, Multi-Processing is the ability to use more than one processor (CPU), on a single machine.

Disadvantages of using semaphores?
Semaphore: It’s a synchronization tool, it’s a variable which accepts non-negative integer values and except for initialization may be accessed and manipulated through two primitive functions wait() & signal().

Disadvantages :
1. Semaphores are unstructured.
2. Semaphores do not support data abstraction.

Alternative to Semaphores:
1. Critical region
2. Conditional critical region
3. Monitors
4. Message Passing

What is dead lock? When does it occur?
A deadlock is a situation where in two or more competing actions are each waiting for the other to finish, and thus neither ever does.

What are the major Conditions for occurring of deadlock?
Deadlock can arise if four conditions hold simultaneously.
Mutual exclusion: Only one process at a time can use a resource.
Hold and wait: A process holding at least one resource is waiting to acquire additional resources held by other processes.
No preemption: A resource can be released only voluntarily by the process holding it, after that process has completed its task.
Circular wait: There exists a set {P0, P1, ?, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, ?, Pn?1 is waiting for a resource that is held by Pn, and P0 is waiting for a resource that is held by P0.

Get current page/post id in wordpress

Get current page/post id in wordpress

If you are customizing wordpress theme then many times you need to get current page id to show/hide some code or change basic functionality in wordpress. If you need the numeric id of the current page, you can get using following function in your wordpress theme file:

$currentid = get_the_ID();

After you have got the page id in $currentid you can easily use it in your php code like:

<?php if($currentid!=”4″)
//do Something

Apply same css style to multiple IDs controls

Apply same css style to multiple IDs controls

How to apply Multiple IDs # on one css?

You can easily apply multiple id’s to a single css style using following format:

#id1, #id2, #ID3 {
} url rewrite rule to redirect http to https url rewrite rule to redirect http to https

<rule name=”HTTP to HTTPS redirect” stopProcessing=”true”>

<match url=”(.*)” />
<add input=”{HTTPS}” pattern=”off” ignoreCase=”true” />
<action type=”Redirect” redirectType=”Found” url=”https://{HTTP_HOST}/{R:1}” />



I was adding a new SSL certificate to one of the client’s website and now we wanted only https accessible and redirect user if he/she tries to access

So, i thought of available options and from all of those he best is to add a rewrite rule and it will take care of redirection and we even don’t have to update the site navigation and other links. :)

Change login page design for Vtiger 6

Change login page design for Vtiger 6

Vtiger is a great Open Source app for companies of all size.
you can install it’s open source version locally and customize based on your needs.
It can be installed in under 5 minutes and you can start using right away.
Vtiger 6 has got new dashboard color themes and layout design.
But, the default login page on vtiger 6 looks really bad and contains a lot of ads for add-ons and social follow links. If you clean up the login page it looks a lot more professional in design.

Please note: Always take backup of all files before making any changes so you can easily revert back if anyting gets broken.

Step 1:- Search for the correct file to modify.
In earlier versions(vtiger 5.2, Vtiger 5.4) template files were placed under
but now they have updated folder structure and in new version of Vtiger 6 the files are located under

Step 2:- Change logo.
In new version of Vtiger logo for login page is used from following path. You can simply remove old logo file and upload new logo image and rename it to be “logo.png”
Login page Logo path:-

Step 3:- Remove slider on left side of login page on Vtiger
Open Login.tpl in your favourite text-editor.
Remove following div along with other contents inside it.

<div class="carousal-container">
<div><h2> Get more out of Vtiger </h2></div>
<ul class="bxslider">
<div id="slide01" class="slide">
<img class="pull-left" src="{vimage_path('android_text.png')}">
<img class="pull-right" src="{vimage_path('android.png')}"/>
<div id="slide02" class="slide">
<img class="pull-left" src="{vimage_path('iphone_text.png')}"/>
<img class="pull-right" src="{vimage_path('iphone.png')}"/>
<div id="slide03" class="slide">
<img class="pull-left" src="{vimage_path('ipad_text.png')}"/>
<img class="pull-right" src="{vimage_path('ipad.png')}"/>
<div id="slide04" class="slide">
<img class="pull-left" src="{vimage_path('exchange_conn_text.png')}"/>
<img class="pull-right" src="{vimage_path('exchange_conn.png')}"/>
<div id="slide05" class="slide">
<img class="pull-left" src="{vimage_path('outlook_text.png')}"/>
<img class="pull-right" src="{vimage_path('outlook.png')}"/>

Step 4:- Change/remove social links at bottom.
You can either completely remove or just change the social links to your own links.
Change following code for it.

<div class="pull-right footer-icons">
<small>{vtranslate('LBL_CONNECT_WITH_US', $MODULE)}&nbsp;</small>
<a href=""><img src="layouts/vlayout/skins/images/facebook.png"></a>
&nbsp;<a href=""><img src="layouts/vlayout/skins/images/twitter.png"></a>
&nbsp;<a href="#"><img src="layouts/vlayout/skins/images/linkedin.png"></a>
&nbsp;<a href=""><img src="layouts/vlayout/skins/images/youtube.png"></a>

Step 5:- Change text links in header and footer of Vtiger login page.
You can change the links or remove them completely.
Mofidy following code for this step.
In Header

<div class="helpLinks">
<a href="">Vtiger Website</a> |
<a href="">Vtiger Wiki</a> |
<a href="">Vtiger videos </a> |
<a href="">Vtiger Forums</a>

Change links in footer

<div class="footer-content">
<small>&#169 2004-{date('Y')}&nbsp;
<a href=""></a> |
<a href="javascript:mypopup();">Read License</a> |
<a href="">Privacy Policy</a> </small>

See attached screenshots for before and after login pages.