Hello,
I have a mysql db with a column with E-mail address. I want use a form and phpmailer that send e-mail to the e-mail address in the database.
But I get the error: Fatal error: Class ‘SMTP’ not found in C:xampphtdocsfolderPHPMailer-masterclass.phpmailer.php on line 1439.
What is going wrong?
can someone help me?
thanks in advance.
this is my form:
[code=php]
<form name=”form1″ id=”form1″ action=”list.php” method=”post”>
<h3>Maak here your E-mail</h3>
<textarea name=”textfield” rows=”4″ cols=”50″></textarea>
<br />
<input type=”submit” name=”submit” value=”Send” />
<p><?php if(!empty($message)) echo $message; ?></p></form>
this is the list.php file:
[code=php]<?php
ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);
if(isset($_POST[‘submit’]))
{
$message=
‘Bericht: ‘.$_POST[‘textfield’].’
‘;
require_once(‘PHPMailer-master/class.phpmailer.php’);
//include(“class.smtp.php”); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
//$body = file_get_contents(‘contents.html’);
//$body = eregi_replace(“[]”,”,$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = “smtp.gmail.com”;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent
//$mail->Host = “mail.yourdomain.com”; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = “[email protected]”; // SMTP account username
$mail->Password = “secret”; // SMTP account password
$mail->Encoding = ‘7bit’;
//$mail->SetFrom(‘[email protected]’, ‘List manager’);
//$mail->AddReplyTo(‘[email protected]’, ‘List manager’);
$mail->Subject = “PHPMailer Test Subject via smtp, basic with authentication”;
$link=mysqli_connect(‘localhost’, ‘root’, ‘secret’, ‘platform’);
if (!$link) {
die(‘==> Could not connect: ‘ . mysqli_error() );
}
$query = “SELECT fullname, e_mail FROM member”;
$result = mysqli_query($link, $query) or die(mysqli_error());
while ($record = mysqli_fetch_assoc($result)) {
$mail->AltBody = “To view the message, please use an HTML compatible email viewer!”; // optional, comment out and test
$mail->MsgHTML($message);
$mail->AddAddress($record[“e_mail”], $record[“fullname”]);
if(!$mail->Send()) {
echo “Mailer Error (” . str_replace(“@”, “@”, $record[“e_mail”]) . ‘) ‘ . $mail->ErrorInfo . ‘<br>’;
} else {
echo “Message sent to :” . $record[“fullname”] . ‘ (‘ . str_replace(“@”, “@”, $record[“e_mail”]) . ‘)<br>’;
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
}
?>