gpt4 book ai didi

php - 无法重新声明 Send_mail() 错误

转载 作者:行者123 更新时间:2023-11-29 07:05:36 24 4
gpt4 key购买 nike

我正在尝试创建一个功能,可以检查数据库中状态为 1 的活跃客户,如果活跃,他们应该收到电子邮件。对于电子邮件功能,我使用了 PHP Mailer 功能。

下面是我的脚本:

<?php
include '../mailer/class.phpmailer.php';
$sqlx = mysql_query("SELECT * from `cust");

$numRows = mysql_num_rows($sqlx);
$mail_body = '';
while($row = mysql_fetch_array($sqlx))
{
// fetch email

$uid = $row["uid"];
$email = $row["email"];

$count = "20";
if($count <= '70')
{
$f_name = "abc";
$f_email = "abc@xyz.com";
$mail_body = "Hii message";
$subject = "Hi you got notificaiton";
$headers = "From: abc <abc@xyz.com>";
$headers .= "Content-type: text/html\r\n";

function Send_mail($email, $subject, $headers, $mail_body, $f_email, $f_name)
{
$mail = new PHPMailer();
$Email = $email;
$fname = $f_name;
$femail = $f_email;
//==================smtp mail ===============================//
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true;
$mail->Port= 25; // Sets the default SMTP server port.
$mail->SMTPSecure= 'tls'; // Options are "", "ssl" or "tls"
$mail->Host = 'localhost'; // SMTP server
$mail->Username = 'abc@xyz.com'; // Sets SMTP username.
$mail->Password = '1234556'; //Sets SMTP password.
//=========================================================//

$fname = $f_name;
$femail = $f_email; // email address of reciever
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = $subject; // subject of mail
$mail->Body = $mail_body; // body of mail
$mail->Send(); return true;
}

$mail_result=Send_Mail($email, $subject, $headers, $mail_body,$f_email, $f_name);


}

}

?>

但是我收到错误:

You must provide at least one recipient email address. Fatal error: Cannot redeclare Send_mail() (previously declared in C:\xampp\htdocs\testing\update.php:161) in C:\xampp\htdocs\testing\update.php on line 161

最佳答案

检查您的客户表,其中必须输入您尝试发送电子邮件的电子邮件地址。并改变你的

$mail->Port= 587; 
$mail->SMTPSecure= 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Username = 'abc@gmail.com';//Valid Gmail address
$mail->Password = '1234556';//Gmail password

如果仍然出现错误,您可以转到 Gmail 帐户设置并允许安全应用身份验证。

关于php - 无法重新声明 Send_mail() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41825096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com