I've created a simple php script I would like to run daily, and I put it in a simple php file in the inc/tasks folder:
./inc/tasks/myscript.php
I then went to ACP > Tools > Task Manager > Add New Task and selected "myscript.php" as the task to run.
When I manually tell it to "run task now" it works, but I can't get the schedule or the logging to work... I tried to understand Mipher's note above, but I don't get it. Is there a simple way to have MyBB run my script on a schedule and log the result? Thanks in advance, sorry for the novice question.
please help me as soon as possible
my great forum link:
https://ajmalworld.com/index.php
Without the content of the file, it's impossible to help you: the bug is in the file, not in MyBB.
(2022-06-26, 11:32 AM)Crazycat Wrote: [ -> ]Without the content of the file, it's impossible to help you: the bug is in the file, not in MyBB.
I am using php mailer with following codes, it run manually but codes not execute automatically
<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.example.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = '[email protected]'; //SMTP username
$mail->Password = 'secret'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Joe User'); //Add a recipient
$mail->addAddress('[email protected]'); //Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Your code is not a complete task code. It's just a script that MyBB can't launch because it lacks all the MyBB parts.
You nead at least a function task_myscript()
(if your file is tasks/myscript.php) which will contain your active content