PHP send email using Gmail SMTP

Problem: We need to send emails from PHP script using Gmail SMTP, when we don't have our own SMTP server.

I am sharing the code that uses the PHP Mailer

Step1: Get the class.phpmailer.php file from above mentioned location. The file's content looks a bit longer but don't worry, most of the content are there as default and should be pretty straightforward to follow:

Step2: Add the class.smtp.php file from the above location which looks like

Step3:Add the PHPMailerAutoload.php from above location, whose content looks like:

Step4: create your sample php script to send the email. I am sharing the sample I worked on:

No comments:

Post a Comment