Hi,

I want to send authenticated mail in php. i know smtp and phpmail classes. Is there anyone to help me? I have followed scripts on net but, i couldn't send an email. Anyone with working solution?

Thanks

The error i receive is "Fatal error: Call to undefined function IsSMTP() in C:\wamp\www\Email\send.php on line 6
"

<?php
include("class.phpmailer.php");
$mail=new PHPMailer();
$mail->IsSMTP();

IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username"; // SMTP username
$mail->Password = "password"; // SMTP password
$webmaster_email = "something@xxx.com"; //Reply to this email ID
$email="something@xxx.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
  echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
  echo "Message has been sent";
}
?>

Also, What do i have to change in class.phpmailer.php file?

Thanks

OR. This one generates "Message Not Sent
Mailer Error: SMTP Error: Could not connect to SMTP host. ". I am very sure about my smtp server.

require("class.phpmailer.php");
  $To = $_POST['To'];
  $From = $_POST['From'];
  $FromName = $_POST['FromName'];
  $Subject = $_POST['Subject'];
  $Message = $_POST['Message'];
  $Host = $_POST['Host'];
  
  if (array_key_exists('HTML',$_POST))
  {
   $HTML = true;
   $Mail->Username=$_POST['Username'];
   $Mail->Password=$_POST['Password'];
  }
  else
  {
   $HTML = false;
  }
  
  $Mail = new PHPMailer();
     
  $Mail->IsSMTP(); // send via SMTP
  $Mail->Host = $Host; //SMTP server
  
  if (array_key_exists('Username',$_POST))
  {
   $Mail->SMTPAuth=true;
  }
  else
  {
   $Mail->SMTPAuth=false;
  } 
  
  $Mail->From = $From;
  $Mail->FromName = $FromName;
  $Mail->AddAddress($To);
  $Mail->AddReplyTo($From);
  
  $Mail->WordWrap = 50; // set word wrap
  $Mail->IsHTML($HTML);
  
  $Mail->Subject  = $Subject;
  $Mail->Body = $Message;
  
  if($Mail->Send())
  {
   echo "Message Sent";
  }
  else
  {
    echo "Message Not Sent<br/>";
    echo "Mailer Error: " . $Mail->ErrorInfo;
  }
 }
?>
This question has already been answered. Start a new discussion instead.