Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

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

the mail() function

Moderators: macek, egami, gesf

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

Postby rocky48 » Fri Feb 21, 2014 4:49 am

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

Code: Select all
<html>
<head>
<title>PHPMailer - MySQL Database - SMTP basic test with authentication</title>
</head>
<body>

<?php
print_r($_POST);
//echo $_POST['Message'];
//echo $_POST['Attachment1'];
//echo $_POST['Subject'];
//error_reporting(E_ALL);
//error_reporting(E_STRICT);

date_default_timezone_set('Europe/London');

require_once('\class.phpmailer.php');
//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']);

include('connect_mailer.php');
doDB5();

echo "connected to database? \n";
if (mysqli_connect_errno()) {
      //if connection fails, stop script execution
      printf("Connect failed: %s\n", mysqli_connect_error());
      exit();
   } 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->AddAddress($row['email']);
      $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->Subject($rowm['subtxt']);
      $mail->MsgHTML($rowm['message']);
      $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
 
$mail->ClearAddresses();
$mail->ClearAttachments();
}
?>

</body>
</HTML>


Despite much research I can't find the reason for the error!
Am I missing something ?
rocky48
New php-forum User
New php-forum User
 
Posts: 16
Joined: Wed Aug 01, 2012 12:57 pm

Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.