Sending Mail using PHP and GMail (smtp)

Here I am demonstrating easiest way of sending mail from your computer. Sending mail from PHP we required some configuration using PEAR packages, which might be more complicated. But here I’m demonstrating third-party package for sending mail. We’re talking about PHPmailer.

To send mail we required SMTP server, which is responsible for sending mail. Web server is not able to send mail it is separate server then the Web server.I’m using SMTP of, we require two things from SMTP. [Turn your PC to Mail Sever].

1. Server address []
2. Port number [465]

If you want to send mail from your local computer without using other global SMTP server like Gmail or Yahoo you can read this article. This is open-source project from Apache. Your local computer will act as SMTP server using JAMES server.

1) Download PHPMailer.
2) Extract to folder within you php project and rename it to phpmailer.
3) Create sentmail.php and paste the following code:

Image 1

4) Now Open PHP.ini file given in bin directory. find PHP_OPENSSL.DLL make enable them by removing “;” save configuration and re-stat the server.

5) Send mail from Browser (e.g. http://localhost/your-project/sentmail.php).

Share Post