Fatal error: Call to undefined method PHPMailer::Subject() i

the mail() function

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 17
Joined: Wed Aug 01, 2012 12:57 pm

Fri Feb 21, 2014 4:49 am

I am getting the above error when I run the following code:

Code: Select all

<title>PHPMailer - MySQL Database - SMTP basic test with authentication</title>

//echo $_POST['Message'];
//echo $_POST['Attachment1'];
//echo $_POST['Subject'];


//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

//$body = $_POST['Message'];
//$attachment	= $_POST['Attachment1'];

//echo $body;
//echo $attachment;

$mail->SetFrom('webmaster@1066cards4u.co.uk', 'List manager');
$mail->AddReplyTo('webmaster@1066cards4u.co.uk', 'List manager');

//$mail->Subject = ($_POST['Subject']);


echo "connected to database? \n";
if (mysqli_connect_errno()) {
		//if connection fails, stop script execution
		printf("Connect failed: %s\n", mysqli_connect_error());
	} else {
		//otherwise, get emails from subscribers list
		$sql = "SELECT email FROM subscribers";
		$result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));

		//create a From: mailheader
		$mailheaders = "From: webmaster@1066cards4u.co.uk>";

		//loop through results and send mail
		while ($row = mysqli_fetch_array($result)) {
			//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
		$mail->SetFrom('administrator@1066cards4u.co.uk', 'Tony Hudson');
$sqlmail = "SELECT subtxt, message, attachment FROM mail_info WHERE EID= '".$_POST['Eno']."'";
		$mailresult = mysqli_query($mysqli, $sqlmail) or die(mysqli_error($mysqli));
		while ($rowm = mysqli_fetch_array($mailresult)) {
		$mail->AddAttachment($rowm['attachment']);      // attachment

if(!$mail->Send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Messages sent!';
// Clear all addresses and attachments for next loop

Despite much research I can't find the reason for the error!
Am I missing something ?

Post Reply