LIMITATIONS OF THE PHP MAIL FUNCTIONS
1. You must modify the PHP.INI file to change email servers.
2. You cannot use an encrypted connection to the email server.
3. You cannot provide a username and password when connecting to the email server
To start you will need to know the Host name of your SMTP server, typically, the hostname is a subdomain name such as smtp,gmail.com or maybe an IP address 192.168.1.10.
Next you will need to know if your SMTP server uses SSL encryption and what port number you need to use. If uses SSL server, the default port is 465. Otherwise is 25. An SMTP server can use any port number, however, so you need to specify the correct port number for your SMTP server.
USING GMAIL ACCOUNT
1. Login to your Gmail account and go to your Inbox
2. Click “Settings” link at the top of the page.
3. On the setting page, click the “Forwarding and POP/IMAP” link
4. In the POP download section, select the “Enable POP for all mail” option.
5. Click the “Save Changes ” button.
CONFIGURATIONS in Mail.php:
Host name: ssl://smtp.gmail.com (use: smtp.gmail.com, if not using SSL)
Encryption: SSL
Port number: 465 (or 25)
Authentication: Yes
Username: username@gmail.com
Password: yourGmailPassword
PHP.INI File
Code:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from =admin@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Or you may check to this site:
PHPMailer tutorial
If in case it will not work locally (as per of my experience), you will need to deploy it to the web hosting site to work.