Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

[Added] Email Logging & Tracking

Information about updates, news, Code Library
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

[Added] Email Logging & Tracking

Unread post by admin »

New Feature Overview:
  • A feature has been added to log and track outgoing emails.
  • Outgoing emails are automatically recorded in a new database table named zzzzsys_email_log.
  • The logging includes information about whether the email was sent successfully or encountered problems, along with all relevant details such as sender, recipient, email body, etc.
Purpose of the Feature:
  • The feature aims to help users keep track of their outgoing emails.
  • It enables the identification of emails that couldn't be sent, allowing users/admins to address and fix any issues.
Implementation Details:
  • The logging is triggered automatically when sending emails using the nuSendEmail() function.
  • Users need to provide a second parameter, $logOptions, which is an array containing log information.
  • The log options can include a 'tag' for categorisation or any other relevant information.

To make use of the new functionality, call nuSendEmail() with a 2nd parameter (array) that contains the log information.

Code: Select all

$logOptions = [
    'tag' => 'some tag here'
];

$sendResult = nuSendEmail([
    'to' => 'someone@test.com',
    'cc' => '',
    'bcc' => '',
    'body' => 'email body here',
    'subject' => 'test subject'
], $logOptions) ;

The default log options that are stored in the database are defined as follows:

Code: Select all

$defaultLogOptions = ['table_name' => null, 'tag' => null, 'form_id' => nuFormId(), 'user_id' => nuUserId(), 'record_id' => nuRecordId(), 'json' => null];
Post Reply