If you want to use gmail smtp server in PHP, php mailer is a good choice for you. Here is the example:
include(“class.phpmailer.php”);
$mail = new PHPMailer ();
$mail->IsSMTP ();
$mail->SMTPAuth = true;
$mail->SMTPSecure = “ssl”;
$mail->Host = “smtp.gmail.com”;
$mail->Port = 465;
$mail->Mailer= “smtp”;
$mail->Username = “username@gmail.com”;
$mail->Password >= “password”;
$mail->AddReplyTo (“Reply Email”, “Recipient Name”);
$mail->From = “sender@gmail.com”;
$mail->FromName = “Sender Name”;
$mail->Subject = “Email Subject”;
$mail->Body = “Email Content…”;
$mail->WordWrap = 50;
$mail->AddAddress (“receiver@gmail.com”, “Receiver Name”);
$mail->IsHTML (true);
$mail->Send ();
However, these simple codes could only work on PHP with enabling the ssl function. If not, you will probably find the warning message in the log file:
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?)
To solve this problem, you have to make sure your php.ini including extension=php_openssl.dll (of course the file should be placed in php extension directory) and copy both libeay32.dll and ssleay32.dll from php directory to apache bin directory.
References:
Just wanna say thanks for the information. I’ve spent days trying to configure PHPMailer and finally found this site which helped me out. Thanks a bunch bro.
You are welcome. I have also spent a day for that problem.