Location: PHPKode > scripts > Contact Form PHP Ajax Script > gmail/gmail.php
<?php
function gmail_sender($to, $gmail_user, $gmail_pass, $subject, $body, $email, $nume) {
  date_default_timezone_set('America/Toronto');

  include_once('class.phpmailer.php');
  //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

  $mail             = new PHPMailer();

  $body             = nl2br($body);
  $body             = eregi_replace("[\]",'',$body);

  $mail->IsSMTP(); // telling the class to use SMTP
  $mail->Host       = "smtp.gmail.com"; // SMTP server
  // $mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                             // 2 = errors and messages
                                             // 1 = messages only
  $mail->SMTPAuth   = true;                  // enable SMTP authentication
  $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
  $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
  $mail->Port       = 465;                   // set the SMTP port for the GMAIL server
  $mail->Username   = $gmail_user;  // GMAIL username
  $mail->Password   = $gmail_pass;            // GMAIL password

  $mail->SetFrom($email, $nume);

  $mail->AddReplyTo($email, $nume);

  $mail->Subject    = $subject;
  $mail->MsgHTML($body);

  $mail->AddAddress($to, "Admin");

  if(!$mail->Send()) { $re = 'Error: '. $mail->ErrorInfo; }
  else $re = 'sent';

  return $re;
}
?>
Return current item: Contact Form PHP Ajax Script