Resource icon

Email Log v1.2.0

No permission to download

stromb0li

Well-known member
stromb0li submitted a new resource:

Email Log - Add-on to allow administrators to keep track of outbound emails sent for quick debugging.

This add-on logs all emails being sent outbound by your website. Logs are retained up to a defined length of time, as defined in the optinos of the add-on. Access to the logs can be delegated via administrator permissions.

Logs shown contain the timestamp the message was sent, username, email address sent to, and message subject. If the user changes their email address, this page will not reflect the user's new email address, it logs the actual address of the email sent at that point in time.

Read more about this resource...
 
This addon assumes that a username is set for outbound email:

PHP:
foreach($emails as $emailAddress => $username){
    $log = \XF::em()->create('Jack\emailLog:EmailLog');
    $user = \XF::finder('XF:User')->where('username', $username)->fetchOne();
    $log->user_id = $user->user_id;
    $log->email = $emailAddress;
    $log->subject = $mail->message->getSubject();
    $log->save();
}

The following (valid) code which cause $username and thus $user to be null:
PHP:
\XF::app()->mailer()->newMail()
   ->setTo($email)
   ->setTemplate($template, $params)
   ->queue();
 
Getting these errors with the latest version:

Code:
    ErrorException: Job XF:FileCheck: [E_WARNING] Attempt to read property "user_id" on null src/addons/Jack/emailLog/XF/Mail/Mail.php:20

    Generated by: Unknown account Mar 21, 2024 at 5:24 PM

Stack trace

#0 src/addons/Jack/emailLog/XF/Mail/Mail.php(20): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/nginx/dom...', 20)
#1 src/XF/Mail/Mail.php(415): Jack\emailLog\XF\Mail\Mail->setContent('File healthchec...', '<!DOCTYPE html>...', 'An automatic fi...')
#2 src/XF/Mail/Mail.php(480): XF\Mail\Mail->renderTemplate()
#3 src/XF/Mail/Mail.php(571): XF\Mail\Mail->getSendableMessage()
#4 src/XF/Job/FileCheck.php(231): XF\Mail\Mail->send()
#5 src/XF/Job/FileCheck.php(110): XF\Job\FileCheck->completeFileCheck(Object(XF\Entity\FileCheck), Array)
#6 src/XF/Job/Manager.php(260): XF\Job\FileCheck->run(8)
#7 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#8 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#9 job.php(43): XF\Job\Manager->runQueue(false, 8)
#10 {main}

Request state

array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(35) "https://forum.domain/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Code:
    ErrorException: [E_WARNING] Attempt to read property "user_id" on null src/addons/Jack/emailLog/XF/Mail/Mail.php:20

    Generated by: Unknown account Mar 21, 2024 at 11:01 PM

Stack trace

#0 src/addons/Jack/emailLog/XF/Mail/Mail.php(20): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/nginx/dom...', 20)
#1 src/XF/Mail/Mail.php(415): Jack\emailLog\XF\Mail\Mail->setContent('Get Big bon... ...', '<!DOCTYPE html>...', 'The following m...')
#2 src/XF/Mail/Mail.php(480): XF\Mail\Mail->renderTemplate()
#3 src/XF/Mail/Mail.php(571): XF\Mail\Mail->getSendableMessage()
#4 src/XF/Service/Contact.php(198): XF\Mail\Mail->send()
#5 src/XF/Pub/Controller/Misc.php(166): XF\Service\Contact->send()
#6 src/XF/Mvc/Dispatcher.php(352): XF\Pub\Controller\Misc->actionContact(Object(XF\Mvc\ParameterBag))
#7 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Misc', 'Contact', Object(XF\Mvc\RouteMatch), Object(Andrew\ModeratorPanel\XF\Pub\Controller\Misc), NULL)
#8 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Andrew\ModeratorPanel\XF\Pub\Controller\Misc), NULL)
#9 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#11 src/XF.php(524): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}

Request state

array(4) {
  ["url"] => string(13) "/misc/contact"
  ["referrer"] => string(47) "https://forum.domain/misc/contact"
  ["_GET"] => array(1) {
    ["/misc/contact"] => string(0) ""
  }
  ["_POST"] => array(10) {
    ["_xfToken"] => string(8) "********"
    ["username"] => string(9) "StevenHeF"
    ["email"] => string(19) "xxx@gmail.com"
    ["subject"] => string(14) "Get Big bon..."
    ["message"] => string(88) "Top online casіos!
Get Big bоnus for frее singup
 
https://tinyurl.com/xxx"
    ["submit"] => string(0) ""
    ["_xfRedirect"] => string(47) "https://forum.domain/misc/contact"
    ["g-recaptcha-response"] => string(2303) "P1_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.hKdwYXNza2V5xQZZhF0lzlE5TiByzaYHwAeh2XT_wfqZhGsD9VvhbT5yK7JZfYRrw5kmI004iChULEC81RsThEL_a8VYAGROdTdJe2MqKfV-xJvNwKVIljwV_2ZcOeIqFXYDj27r6Nd8Mq6wM-UMtGE1QgznEEAiZniTBlIhWP4DhvyZRFmSBTbD3jYs1UUutZo4aK_vO2GXIk-DUgt0MAoPdJQJKQELwfFcUxrAhZVesm8WvZvEyJACKw5TjY6etpPYx2didiMy5H53Ca3kixaMGz-CpHKwPA5iZVDtt7i3UPDlfpi_l9lsgc-n8Vz91-et_-2_fQd1GzwcD3lG_09mhTXvqYa6EN_KV4JdqKg5tMLZbkbRFgK1bbjWjNSWU8tXuhetEo7dfT1AsqVNXLALSSZDYQFBm-BKXiq_VAmFhzTtHpTN_QUDyCLXG9fKiIhE4Wt6OEIBQYShheDA8qqKhMOq8xHKzDuU3pVCO-2ACTScbJ7kyQzW0jf_HQFEgrCeuk9e7vUuxABUyRPIkzk3w3JearVoRjsZPVh7ts7e4lWG3XYoAKe-C76S-2QR8Uepve8ckzBZVBMx3fAETvRpWkENYXKM03BWJJXSfeoZ-aOhfUecHlWoJBDPcRDa1FcsdMDFFz7hIRXLt-KANhIFKsrm2KHE7qfAOIRPay1DEUFReL3N61cyGUGjwXX505Af-GoONnZtHu5BKojWMlRIGFSD0SWwCsf17DqLSDoZybDmpxQvd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gWvB_yJU9tSXvSAFt8TBr_gcTQK4UEeXzTR0zlb45hdCaXCLHM3Yqzm7JpDR_2SjcjqhxM07D-6dgQtBP7mspgfCbUG8fQdA9e--QPzOXLhS8VGQJKYuiy-3FqA7B_nWu2vuUuCkYvowBiLy0mshJJ0CHJEzSH141rx5qisnjDXg55X_17-6n5Ab3k5Xk8-63XK0poCiaWFzpPnkFFKgTsaHkN_jl7eMPTA1Z1Y2_oSLvEkgiNsEV5_KCK2iGdKoEtM6wK7K8iRt8n-N-qLYXr4aYDxjR8y1Iyr9aIBJvz37johG92HhwKcWRg0K_aPGajAa38oqxqCIIB_NxghmZfXdnrMqedkpSIpTOUe_TfHco_LV6e5L97Udc3W4Atxqe1X5MPOMfpH8YqzlwEDmFcNlXscIfXsnB0MiwRGXiNSRmWEwhYh0RkGwPSm_q1Tregn5P8UKQ139AeAJGyg6JfHj0OGuvKRsWTcJPJlOJUWOJm4WLw-MCqiNalWSBuoIw6jZXhwzmX9HyCoc2hhcmRfaWTOAzGDb6JwZAA.zOTFGYO6u_uQPqom6ji-lRNTif9egdSmugFc_ljrxd4"
    ["_xfRequestUri"] => string(48) "/misc/contact&_xfWithData=1&_xfResponseType=json"
  }
}
 
Getting these errors with the latest version:

Code:
    ErrorException: Job XF:FileCheck: [E_WARNING] Attempt to read property "user_id" on null src/addons/Jack/emailLog/XF/Mail/Mail.php:20

    Generated by: Unknown account Mar 21, 2024 at 5:24 PM

Stack trace

...
This is the same issue Xon bubbled up. Will try to publish an update tonight or tomorrow.
 
Hello,
even after udate I get errors:

  • ErrorException: Job LiamW\AccountDelete:DeleteAccounts: [E_WARNING] Attempt to read property "user_id" on null src/addons/Jack/emailLog/XF/Mail/Mail.php:22

#0 src/addons/Jack/emailLog/XF/Mail/Mail.php(22): XF::handlePhpError(2, '[E_WARNING] Att...', '/www/htdocs/w01...', 22)
#1 src/XF/Mail/Mail.php(415): Jack\emailLog\XF\Mail\Mail->setContent(xxxxx...', '<!DOCTYPE html>...', 'xxxxx, xxx...')
#2 src/XF/Mail/Mail.php(480): XF\Mail\Mail->renderTemplate()
#3 src/XF/Mail/Mail.php(571): XF\Mail\Mail->getSendableMessage()
#4 src/addons/LiamW/AccountDelete/Service/AccountDelete.php(408): XF\Mail\Mail->send()
#5 src/addons/LiamW/AccountDelete/Service/AccountDelete.php(241): LiamW\AccountDelete\Service\AccountDelete->sendCompletedEmail()
#6 src/addons/LiamW/AccountDelete/Service/AccountDelete.php(192): LiamW\AccountDelete\Service\AccountDelete->finaliseDeleteDisable()
#7 src/addons/LiamW/AccountDelete/Job/DeleteAccounts.php(45): LiamW\AccountDelete\Service\AccountDelete->executeDeletion()
#8 src/XF/Job/Manager.php(260): LiamW\AccountDelete\Job\DeleteAccounts->run(8)
#9 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#10 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#11 job.php(43): XF\Job\Manager->runQueue(false, 8)
#12 {main}

Maybe you could help, thx in advance

Kai
 
Hello,
even after udate I get errors:

  • ErrorException: Job LiamW\AccountDelete:DeleteAccounts: [E_WARNING] Attempt to read property "user_id" on null src/addons/Jack/emailLog/XF/Mail/Mail.php:22
Maybe you could help, thx in advance

Kai
Please upgrade to v1.1.2; should solve for this.
 
It's fine grain delegatio
Rookie admin here - I am confused by your 3rd image on how to set admin permissions to view the reporsts.?
Super administrators have the permission, but if you have "regular administrators" where you only delegate a subset of permissions, the checkbox allows fine-grain access to the log.
 
Can you add a pagination for logs and a way to delete specific logs?
I want to maintain certain logs for more time, but the list will be bigger. Will be nice some ways to clear specific entries and navigate to the log.

This addon is awesome. It's a feature that should be in the core of Xenforo.
 
Can you add a pagination for logs and a way to delete specific logs?
If adding pagination, please ensure you add search and filtering functionality.
Right now, I can use browser search functionally to find what I'm looking for.
Add pagination and it becomes difficult and time consuming.
 
Back
Top Bottom