IT BS Help

PHP Mailer Fatal error: Class ‘SMTP’ not found

in Coding

Make sure You should not require class.phpmailer.php.

Replace: require “class.phpmailer.php”; with require “PHPMailerAutoload.php”; and it will work just fine. Example below.


//The true param means it will throw exceptions on errors, which we need to catch
$mail = new PHPMailer(true);
//Telling the class to use SMTP

try {
$mail->Host = “”; // SMTP server
$mail->Port = 25; // set the SMTP port
$mail->SetFrom(‘[email protected]’, ‘from user’);
$mail->AddAddress(‘[email protected]’, ‘to user’);
$mail->Subject = ‘test with embed image’;

$mail->AddEmbeddedImage(“image.PNG”, “my-attach”, “image.PNG”);

$mail->Body = ‘Your <b>HTML Email Test</b> with an embedded Image: <br /><br /><img src=”cid:my-attach”> <br /> Here is an image!’;

//$mail->AddAttachment(‘image.png’); // this is a regular attachment (Not inline)

echo “Message Sent OK<p></p>\n”;
} catch (phpmailerException $e) {
echo $e->errorMessage(); //error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //error messages from anything else