/    Sign up×
Community /Pin to ProfileBookmark

phpmailer send not e-mail from database E-mail address

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>[/code]

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();
}

}
?>[/code]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmFeb 23.2016 — Perhaps you can point out the line giving you this error message?
Copy linkTweet thisAlerts:
@wesley5authorFeb 23.2016 — I done.

On my from page I have no errors, but the page list.php give the same error:

Fatal error: Class 'SMTP' not found in C:xampphtdocsfolderPHPMailer-masterclass.phpmailer.php on line 1439

how is this possible?
Copy linkTweet thisAlerts:
@ginerjmFeb 23.2016 — Again - perhaps you could point out (ie, SHOW US) the line with the error?
Copy linkTweet thisAlerts:
@wesley5authorFeb 23.2016 — oke, the line in class.phpmailer.php is: $this->smtp = new SMTP;

the function is:

public function getSMTPInstance()

{

if (!is_object($this->smtp)) {

[B]$this->smtp = new SMTP;[/B]//this is line 1439

}

return $this->smtp;

}
Copy linkTweet thisAlerts:
@ginerjmFeb 23.2016 — So it stands to reason that you are not defining the SMTP class. You are using the correct case I hope. See if you can find that line (ie, the class header).
Copy linkTweet thisAlerts:
@NogDogFeb 23.2016 — Look inside PHPMailer-master/class.phpmailer.php and see where it refers to the SMTP class file (presumably in a require() or include() statement). Make sure the path it is using to get that file is correct.
×

Success!

Help @wesley5 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...