Step 1: Install php mailer any version (before that yo have to config your Lamp/Wamp)
Step 2: Use this code for sending and receiving of mail
include("/var/www/PHPMailer_v2.0.4/class.phpmailer.php"); include("/var/www/PHPMailer_v2.0.4/class.smtp.php");$mail = new PHPMailer(); $body = $mail->getFile("location of file to attach");// You can attach text file or HTML over here$body = eregi_replace("[\]",'',$body);$mail->IsSMTP();
$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 = "xx@gmail.com"; // GMAIL username
$mail->Password = "xx"; // GMAIL password
$mail->AddReplyTo("to replay @gmail.com","Name "); $mail->From = "From gmail@gmail.com";
$mail->FromName = "Name";
$mail->Subject = "Conformation was done";
$mail->Body = "Hi,This is the HTML BODYWelcome"; //HTML Body
$mail->Altbody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddAddress("to_address@gmail.com", First name);// Add to address over Here $mail->AddAttachment("/var/www/header.gif"); // attachment $mail->IsHTML(true); // send as HTML
if(!$mail->Send())
{ echo "Mailer Error: " . $mail->ErrorInfo;
}
else { echo "Message sent!"; } ?>
Hope this will be very use full.. I used it gained very much.. Try it by yourself...
No comments:
Post a Comment