Tuesday, 2 June 2015

Php Send mail By php mailer library

this is the code for send mail using php Mailer

<?php
require 'PHPMailer/PHPMailerAutoload.php';
 
$mail = new PHPMailer;
 
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'abc@gmail.com';
$mail->Password = '******';
$mail->SMTPSecure = 'tls';
 
$mail->From = 'abcw@gmail.com';
$mail->FromName = 'abc xyz';
$mail->addAddress('defgw@example.com', 'some one');
 
$mail->addReplyTo('abc.amalw@gmail.com', 'some other');
 
$mail->WordWrap = 50;
$mail->isHTML(true);
 
$mail->Subject = 'Using PHPMailer';
$mail->Body    = 'Hi.. this is email body';
 
if(!$mail->send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}
 
echo 'Message has been sent';

?>

this is simple and secured method to send mail


this mail is not receive in spam or other folders because it is secured

No comments:

Post a Comment