5
SOS我想向選定的電子郵件發送一條消息(由表單發送),以便表單將student_id傳遞給獲取相應student_email地址的php腳本student_id),,, 我非常感謝你的幫助。 這是錯誤消息時每次都遇到,,
Invalid refreshed: You must provide at least one recipient email address. Message was not sent PHP Mailer Error: You must provide at least one recipient email address.
代碼:
<?php require_once("connection.php"); ?>
<?php require_once("functions.php"); ?>
<?php require("class.phpmailer.php");?>
<?php
// START FORM PROCESSING
if(isset($_POST['submit'])) { // Form has been submitted.
$student = trim(mysql_prep($_POST['student']));
$re_mail =$student["email"];
$mail = new PHPMailer();
$mail->PluginDir = './';
$mail->IsSMTP();
$mail->Port = 465;
$mail->Host = "smtp.gmail.com";
$mail->IsHTML(true);
$mail->Mailer = "smtp";
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxxxxxx";
$mail->SingleTo = true; // if you want to send mail to the users individually so that no recipients can see that who has got the same email.
$mail->From = "[email protected]";
$mail->FromName = "xxxxxxxxx";
$mail->addAddress($re_mail);
$mail->Subject = "Testing PHP Mailer with localhost ";
$mail->Body = "Hi,This system is working perfectly.";
if(!$mail->Send())
echo "Message was not sent PHP Mailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";}
?>
<html>
<body>
<form id="form1" name="form1" method="post" action="">
<span id="spryselect1">
<label>Email:
<select name="student" id="student" tabindex="1">
<?php
$students = get_all_students();//this function works fine
while ($student = mysql_fetch_array($students)) {
echo "<option value=\"{$student["id"]}\"> {$student["first_name"]}</option> ";
}
?>
</select>
</label>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</p>
</form>
</body>
</html>
注: 我有這個功能我function.php
function get_all_students() {
global $connection;
$query = "SELECT *
FROM student ORDER BY first_name ASC";
$student_set = mysql_query($query, $connection);
confirm_query($student_set);
return $student_set;
}
請張貼不工作 – 2010-12-23 17:46:26