Hello Friends !! TOday I found that how PHP mail() function works with SMTP.
Actually when your site is hosted on windows server, then there is SMTP used for sending mail. With simple mail() function ,you can’t send mail in SMTP.
You have to authenticate PHP and SMTP. In short, I explain you that how to send PHP mail using SMTP ?
For sending mail in PHP using SMTP, first of all you have to download phpMailer. phpMailer is a class which used to send mails using SMTP.
You can download phpMailer from here.
//this is a path to PHP mailer class you have dowloaded
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = “SMTP server name “; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = “SMTP username “; // SMTP username
$mail->Password = “SMTP password”; // SMTP password
$mail->From = “frm Email “; //do NOT fake header.
$mail->FromName = “MailMan”;
$mail->AddAddress(“to email ID “); // Email on which you want to send mail
$mail->AddReplyTo(“Reply to Email “, “Support and Help”); //optional
$mail->Subject = “Just a Test”;
$mail->Body = “Hello. I am testing <b>PHP Mailer.</b>”;
echo “email was sent”;
Please save above code as testmail.php or whatever name you want but make it php.
Please make sure that above script is stored in the folder in whu\ich you store class.phpmailer.php and class.smtp.php. These both class files are required for sending mail.
Thats it !! Now you can send PHP mails using SMTP. Feel free to comment on this post. Your feddback is importand to us.