Send PHP mail using SMTP

Hi friends.In this article am going to explain how PHP mail() function works with SMTP.

You need PHPMailer to send mail using SMTP.

phpMailer is a classic email sending library in pHP.

You can download phpMailer from here.



Mail.php

<?php

//PHPMailer Library File
include("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); //Set PHP Mailer

$mail->Host = "SMTP server name "; //Replace with your SMTP server Name

$mail->SMTPAuth = true; //SMTP authentication

$mail->Username = "SMTP username "; // SMTP username

$mail->Password = "SMTP password"; // SMTP password

$mail->From = "from email id"; //Headers for mail function

$mail->FromName = "Vinothkumar";//From person Name

$mail->AddAddress("to email"); // To mail .Replace with your test mail id.

$mail->AddReplyTo("Reply to Email ", "test@codeinnovators.com"); //replace with your mail id

$mail->IsHTML(true); //Mail type (HTML or Plain)

$mail->Subject = "Subject";//subject for your mail

$mail->Body = "Hi This is test mail for PHPMailer";//Body of email

if(!$mail->Send())
{
echo $mail->ErrorInfo; //Shows error message
}
else{
echo "Thank you.Successfully Submitted";
}

?>

Don't forget to include PHPMailer library files.
No comments

No comments :

Post a Comment