I am trying to make a mailing system where by the user can select a specific group of people to send emails. What I am currently facing now is that I couldn't send out emails.
I had tried $row['email'], but it will show me error message like
Fatal error: Cannot use object of type stdClass as array
I has also tried $row->$email, no errors found but no email was to send out.
NOTE: I would prefer using Gmail SMTP because I did not have hosting server set up, and I do not have the time to do that anymore. Please kindly advise.
From doMailingSystem.php,
<?php
include 'dbFunctions.php';
include "mailingSystem.php";
require_once('class.phpmailer.php');
require_once('PHPMailerAutoload.php');
extract($_POST);
$session_id = date('Y-m-d', strtotime($session_id));
$sql = "SELECT student_profile.email FROM student_profile, booking_history WHERE student_profile.student_id = booking_history.student_id and booking_history.booking_date_session LIKE '$session_id%' ";
//print $sql;
$result = mysqli_query($link, $sql);
while ($row = mysqli_fetch_object($result)) {
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = "UTF-8";
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = '[email protected]';
$mail->Password = 'password';
$mail->SMTPAuth = true;
$mail->From = '[email protected]';
$mail->FromName = 'X Team';
$mail->AddAddress($row['email']);
$mail->IsHTML(true);
$mail->Subject = $_POST['subject'];
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = $_POST['message'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<p>
<?php
// echo $statusMessage;
?>
</p>
</body>
</html>
->propertyfor types ofStdClass.['index']is for arrays.extract($_POST);. Words can't describe how bad an idea that is.