Download class files of
class.phpmailer.php
class.smtp.php
Then Use the below code
function mymail($email,$name, $from_email="info@domain.com", $from_name="info",$mail_subject, $mail_message)
{
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "username@domain.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->From = $from_email;
$mail->FromName = $from_name;
$mail->AddAddress($email,$name);
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = $mail_subject;
$mail->Body = $mail_message; //HTML Body
$mail->AltBody = $mail_message; //Text Body
if(!$mail->Send()) return 0;
else return 1;
}
This code works well with google apps domain and gmail smtp sending methods.
Please change the email id and password with required values