reference:
http://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
A full-featured email creation and transfer class for PHP
http://github.com/PHPMailer/PHPMailer
source : http://asif18.com/7/php/send-mails-using-smtp-in-php-by-gmail-server-or-own-domain-server/
http://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
A full-featured email creation and transfer class for PHP
http://github.com/PHPMailer/PHPMailer
source : http://asif18.com/7/php/send-mails-using-smtp-in-php-by-gmail-server-or-own-domain-server/
JavaScript:
<?php
include "classes/class.phpmailer.php"; // include the class file name
if(isset($_POST["send"])){
$email = $_POST["email"];
$mail = new PHPMailer; // call the class
$mail->IsSMTP();
$mail->Host = SMTP_HOST; //Hostname of the mail server
$mail->Port = SMTP_PORT; //Port of the SMTP like to be 25, 80, 465 or 587
$mail->SMTPAuth = true; //Whether to use SMTP authentication
$mail->Username = SMTP_UNAME; //Username for SMTP authentication any valid email created in your domain
$mail->Password = SMTP_PWORD; //Password for SMTP authentication
$mail->AddReplyTo("reply@yourdomain.com", "Reply name"); //reply-to address
$mail->SetFrom("from@yourdomain.com", "x SMTP Mailer"); //From address of the mail
// put your while loop here like below,
$mail->Subject = "Your SMTP Mail"; //Subject od your mail
$mail->AddAddress($email, "Asif18"); //To address who will receive this email
$mail->MsgHTML("[B]Hi, your first SMTP mail has been received. Great Job!.. <br/><br/>by <a href='http://asif18.com']Asif18</a></b>");
$mail->AddAttachment("images/asif18-logo.png"); //Attach a file here if any or comment this line,
$send = $mail->Send(); //Send the mails
if($send){
echo '<center>
[SIZE=5]Mail sent successfully[/SIZE]</center>';
}
else{
echo '<center>
[SIZE=5]Mail error: [/SIZE]</center>'.$mail->ErrorInfo;
}
}
?>