I just changed following line
$smtp->host_name="smtp.gmail.com"; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
$smtp->host_port=465; /* Change this variable to the port of the SMTP server to use, like 465 */
Getting this error
Resolving SMTP server domain "smtp.gmail.com"...
Connecting to host address "184.108.40.206" port 465...
Connected to SMTP server "smtp.gmail.com".
Could not send the message to email@example.com. Error: it was not possible to read line from the SMTP server: data access time out
Manuel Lemos - 2011-07-07 02:41:59 - In reply to message 1 from hafeez
This means that the SMTP server is taking too long to respond. You can increase the timeout variable to an higher value. If it still does not work, it may be a problem related with your machine IP address which may not have a reverse DNS record (PTR).