Here we are using PHPMailer for send emails using SMTP in php
It is very easy process.....
Now Create File Name as "Demomail.php".
<?php include("mail/class.phpmailer.php"); $mail = new PHPMailer(); $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 like to be 25, 80,465,587 $mail->Username = "knowledgecorner.srinu@gmail.com"; // Sender GMAIL username $mail->Password = "XXXXXXXX"; //Sender GMAIL password $mail->From = "kc"; $mail->FromName = "Knowledge Corner"; $mail->Subject = "Demo mail"; $mail->AltBody = "This is the body when user views in plain text format"; //Text Body $mail->WordWrap = 50; // set word wrap // body message you can place html code here $mail->MsgHTML("<b>This is first amil from KnowledgeCorner through SMTP</b>"); //Attach a file here if any or comment this line, $mail->AddAttachment("images/blogicon.jpeg"); //reply-to address of your domain mail id and name $mail->AddReplyTo("knowledgecorner.srinu@gmail.com","KC"); //To address and name who will receive this email $mail->AddAddress("XXXXX@gmail.com","XXX"); $mail->IsHTML(true); // send as HTML if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } ?>
No comments:
Post a Comment