PHPMailer, you may have used it before and of course you should know PHP too to continue this tutorial otherwise you won’t get anything. PHPMailer is very handy – easy to use among all 3rd party mail sender application available out there. PHPMailer supports nearly all possiblities to send email: mail(), Sendmail, qmail & direct to SMTP server. We usually use PHPMailer for our individual web hosting email accounts. This time we are going to configure it and send email from our regular Gmail accounts. Please try the script below as the configuration is well tested and working absolutely fine.
As you may know, it is simply to send mails with the PHP mail() function. So why use PHPMailer? Isn’t it slower? Yes that’s true, but PHPMailer makes it easy to send e-mail, makes it possible to attach files, send HTML e-mail, etc. With PHPMailer you can even use your own SMTP server and avoid Sendmail routines used by the mail() function on *nix platforms.
Here is the PHPMailer home site : http://www.worxware.com/ and please visit http://phpmailer.worxware.com/index.php?pg=tutorial for a complete tutorial of PHPMailer from it’s home site.
PHPMailer configuration for Gmail
<?php $to_name = "Recipient Name"; $to = "[email protected]"; $subject = "Subject"; $message = "A quick brown fox juumped over the lazy dog."; $message = wordwrap($message,70); $from_name = "your_gmail_ID"; $from = "[email protected]"; // phpMailer $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "smtp.gmail.com"; //enable php socks to make SSL it working $mail->Port = 465; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Username = "[email protected]"; $mail->Password = "your_gmail_password"; $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body = $message; $mail->IsHTML(true); $result = $mail->Send(); echo $result ? 'Sent' : 'Error'; // this line is optional - comment out as your need ?>
Please give me your feedbacks. Thank you 🙂