send mail using SMTP authentication :: phpmailer script
« on: February 04, 2007, 01:42:44 PM »

Now a day, most of the hosting providers disable nobody user on their server or do not allow to send mail through script without SMTP authentication to stop the spamming from their servers. In such cases, you have to use SMTP authentication to send mail through PHP, ASP, or ASP.Net script. Below is the sample SMTP authentication script to send mail through PHP script:


$mail = new PHPMailer();

$mail->IsSMTP();                                // send via SMTP
$mail->Host     = ""; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "";   // SMTP username
$mail->Password = "password"; // SMTP password

$mail->From     = "";
$mail->FromName = "Name";
$mail->AddReplyTo("","Your Name");

$mail->WordWrap = 50;                              // set word wrap
$mail->IsHTML(true);                               // send as HTML

$mail->Subject  =  "Here is the subject";
$mail->Body     =  "This is the <b>HTML body</b>";
$mail->AltBody  =  "This is the text-only body";

   echo "Message was not sent <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;

echo "Message has been sent";


Note: To use above script, PHPMailer must be installed on the server. For more information, go to

« Last Edit: November 15, 2015, 01:27:45 AM by Kailash »