require_once('my_phpmail/PHPMailerAutoload.php');
The included file PHPMailerAutoload.php is part of the zip file you have downloaded and installed to use PHPmailer class. All details are explained in our previous tutorial on PHPMailer.
<?php
$bodytext=' Hi this is my body text ';
echo $bodytext;
$subject= ' Message Subject'.date(" H:i:s", time());
echo "<br> $subject <br>";
require_once('my_phpmail_folder/PHPMailerAutoload.php');
$email = new PHPMailer();
$email->isSMTP();
$email->Host = localhost;// Try your mail host address
//$email->Host = "relay-hosting.secureserver.net";
$email->Port = 25;
$email->SMTPAuth = false;
$email->SMTPSecure = false;
$email->Username = "userid@example.com";
$email->Password = "yourpassword";
$email->From = 'userid@example.com';
$email->FromName = 'Your name here';
$email->Subject = $subject;
$email->Body = $bodytext;
$email->AddAddress('name@example.com');
$email->AddAddress('name@example.com');
//$file_to_attach = 'templates/top.php';
//$email->AddAttachment( $file_to_attach,'Your file here');
if(!$email->send())
{
echo "Mailer Error: " . $email->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
PHP MailPHPMailer class
PHPMailer class using SMTP
Sending Multiple Mails
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.