Cannot redeclare Send_mail() error
fatal error: cannot redeclare function wordpress
fatal error: cannot redeclare wp_get_user_request_data
cannot redeclare wp_privacy_process_personal_data_export_page
fatal error: cannot redeclare get_available_post_mime_types
fatal error: cannot redeclare true_plugins_activate previously declared
wp errors
wordpress debugging error
I m trying to make a function which can check the database for active customer whose status is 1 if active, they should receive email. For Email Functionality I had used PHP Mailer function.
Below is my script:
<?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); } } ?>
take your function outside of loop.Change your code structure to this.
function Send_mail($email, $subject, $headers, $mail_body, $f_email, $f_name) { ................//code $mail->Send(); return true; } while($row = mysql_fetch_array($sqlx))//use mysqli or PDO { .......//code if($count <= '70') { .......//code $mail_result=Send_mail($email, $subject, $headers, $mail_body,$f_email, $f_name); } }
Fatal error: Cannot redeclare sendmail(), Hello, I have a problem with JA Job Board, here is the debug log: Fatal error: Cannot redeclare sendmail() (previously declared in New install on Windows XP, XAMMP 1.7.0. SMTP test works fine. When creating a new user or contact existing user, I get this message. Fatal error: Cannot redeclare class SMTP in E:\xampp\htdocs\home\modules\smtp\phpmailer\class.smtp.php on line 36 The e-mail is sent fine.
check your cust table there must be entered email address on which you are trying to send email. And change your
$mail->Port= 587; $mail->SMTPSecure= 'tls'; $mail->Host = 'smtp.gmail.com'; $mail->Username = 'abc@gmail.com';//Valid Gmail address $mail->Password = '1234556';//Gmail password
if still getting error you can go to your gmail account setting and allow for secure app authentication.
Update fail message: “Fatal error: Cannot redeclare , 5 (to the best of my ability to know since I can't access the website.) This is the message I am getting now: Fatal error: Cannot redeclare get_paged_template() ( Stack Overflow Public questions and answers; Teams Private questions and answers for your team; Enterprise Private self-hosted questions and answers for your enterprise; Jobs Programming and related technical career opportunities
Put your function outside of the loop. Here is the code structure:
<?php include '../mailer/class.phpmailer.php'; 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; } $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"; $mail_result=Send_Mail($email, $subject, $headers, $mail_body,$f_email, $f_name); } }
?>
Fatal error: Cannot redeclare sendemail(), Hi, I got this error when clicking on the link on my home page following the job application tutorial: Fatal error: Cannot redeclare sendemail() in Fatal error: Cannot redeclare Test::test() in /path/to/file.php on line 14 This is because a PHP class cannot have two functions with the exact same name. Note that I used public on the first function and protected on the second function because I wanted to demonstrate how the visibility of the method does not matter in this case.
The good and the bad and the ugly of PHP · GitHub, Fatal error: Cannot redeclare sendMail() (previously declared in /exposure-server/src/frontend/app/include/sendmail.php on line 18 Call Stack # Time Memory I have a function called parseDate, but when i call it on my php page (it's a joomla component page) I get Fatal error: Cannot redeclare parsedate() (previously declared in templates/ja_zeolite/ass
How to fix phpmailer?, Fatal error: Cannot redeclare Send_Mail() (previously declared in D:\orion.com\pages\email\reg.php:2) in D:\orion.com\pages\email\reg.php on Erro “Fatal error: Cannot redeclare (previously declared)” [fechada] Faça uma pergunta Perguntada 3 anos, 1 mes atrás. Ativa 3 anos, 1 mes atrás.
Wtf, Edit: heres what pops up under fatal error. Fatal error: Cannot redeclare send_mail() (previously declared in /home/bf/public_html/functions.php:4) in Find articles about information features, troubleshooting guides, and other technical information related to the hosting service Hostinger.
Comments
- Switch to mysqli or PDO.
- Then call your function
Send_mail()
something else as phpMailer obviously has a function with that name. For examplemySend_mail()
- Every time you use the
mysql_
database extension in new code a Kitten is strangled somewhere in the world it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning thePDO
ormysqli
database extensions and prepared statements. Start here - Also, you are declaring your function as
Send_mail
and then calling it asSend_Mail
with a capital M - you have written the function
inside while
take it out and call it in loop. - I tried your code but getting error
Fatal error: Call to undefined function Send_mail()
- I renamed the function then also getting same error :
Fatal error: Call to undefined function mySend_mail()
- @RiyaPatel lets take small steps: comment entire code and try this:
while($i == 0) { $i=1; Send_mail(); } function Send_mail() { echo "hi"; }
and see if it is printing hi. - it showing twoo error
Notice: Undefined variable: i in
andFatal error: Call to undefined function Send_mail() in
- @RiyaPatel that code should work fine and print hi once.create a new php page and run it do not add anything else. demo here sandbox.onlinephpfunctions.com/code/…
- getting same error
Fatal error: Call to undefined function Send_Mail()
- error gone but getting notice
You must provide at least one recipient email address. You must provide at least one recipient email address.
- check your cust table there must be entered email address on which you are trying to send email. And change your SMTP Details ----------TRY THIS FOR GMAIL ACCOUNT---------------------- $mail->Port= 587; $mail->SMTPSecure= 'tls'; $mail->Host = 'smtp.gmail.com'; $mail->Username = 'abc@gmail.com';//Valid Gmail address $mail->Password = '1234556';//Gmail password ----------------------------------------------------------------------------- if still getting error you can go to your gmail account setting and allow for secure app authentication.