Strict Standards: Declaration of RSS::DoAction() should be compatible with CMSModule::DoAction($name, $id, $params, $returnid = '') in /home/xandaorg/public_html/modules/RSS/RSS.module.php on line 114

Strict Standards: Non-static method PageInfoOperations::LoadPageInfoByContentAlias() should not be called statically in /home/xandaorg/public_html/index.php on line 149

Warning: Cannot modify header information - headers already sent by (output started at /home/xandaorg/public_html/modules/RSS/RSS.module.php:114) in /home/xandaorg/public_html/index.php on line 294
Xanda - /dev/project - Use GMail SMTP to send mail in PHP

Maybe some of use might face difficulty to use mail() in PHP espesially when the server is behind firewall or the is no SMTP application running on the server.

In this case, you might need an external SMTP server to push the email. Here i would like to suggest you guys to use phpmailer class.

Here is the example to use it. But first, you need to download phpmailer class first and create the following file in the same directory with phpmailer

<?php
include("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // use ssl
$mail->Host = "smtp.gmail.com"; // GMAIL's SMTP server
$mail->Port = 465; // SMTP port used by GMAIL server
$mail->Username = "your_gmail_account@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->AddReplyTo("other_email@hotmail.com","FirstName LastName"); // Reply email address
$mail->From = "your_gmail_account@gmail.com";
$mail->FromName = "FirstName LastName"; // Name to appear once the email is sent
$mail->Subject = "Subject of the email"; // Email's subject
//$mail->Body = "Hello World,<br />This is the HTML BODY<br />"; //HTML Body
$mail->AltBody = "This is a test email"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body); // [optional] Send body email as HTML
$mail->AddAddress("example@yahoo.com", "First Last"); // email address of recipient
//$mail->AddAttachment("files/files.zip"); // [optional] attachment
$mail->IsHTML(true); // [optional] send as HTML
if(!$mail->Send())
echo "Mailer Error: " . $mail->ErrorInfo;
else
echo "Message sent!";
?>

Enjoy! ;)