User Tools

Site Tools


emails

Email Tracking

When an email is sent using a function in Wizard's Toolkit it is also saved into the wtkEmailsSent SQL data table so they can be viewed directly by associated users as a means of tracking outbound emails and internal communications.

Emails can be sent by calling one of the following:

  • wtkSendMail
  • wtkNotifyViaEmailPlain
  • wtkNotifyViaEmail

All of these call wtkSaveEmailSent which saves the data into the wtkEmailsSent table.

wtkSendMail

This function requires filling an array with the relevant information to send the email. For the technical specifications see wtkSendMail Specs

wtkNotifyViaEmailPlain

One-line method of sending an email without any email HTML template. This builds the array and calls wtkSendMail. For the technical specifications see wtkNotifyViaEmailPlain Specs

wtkNotifyViaEmail

Probably the most useful and used function, this is a one-line method of sending an email using an email HTML template. For the technical specifications see wtkNotifyViaEmail Specs

Parameters

  • Subject
  • Email Body
  • ToEmail (defaults to sending to Tech Support if left blank)
  • SaveArray (see below)
  • CC (defaults to blank)
  • HTML Template (defaults to use emailLight.htm or emailDark.htm based on your wtkServerInfo settings)
  • ReplyTo (defaults to blank)
  • AddNL2BR (defaults to 'N', if set to 'Y' then uses nl2br() on passed Email Body)

wtkEmailsSent Data

Outbound emails are saved in the wtkEmailsSent SQL table. This tracks all of the following:

  • who sent the email
  • who it was sent to
  • when it was sent
  • subject of email
  • body of the email
  • the Email Type
  • when it was opened

SaveArray

If this is not passed then when calling above functions, then only the following are saved in the wtkEmailsSent data table:

  • EmailAddress
  • Subject
  • EmailBody

The following can be passed in the array as additional information to be saved in the wtkEmailsSent table.

  • FromUID
  • ToUID
  • EmailUID
  • EmailType
  • OtherUID

The FromUID is for tracking the wtkUsers.UID of the person initiating the email.

The ToUID is for tracking the wtkUsers.UID of the person receiving the email.

The EmailUID should be used if the wtkEmailTemplate was used. wtkEmailTemplate is a method of making email templates within Wizard's Toolkit and then allowing the user to send directly using that template or you may allow them to modify the text before sending.

The EmailType is a varchar(8) which you can use for tracking different types of emails. For example if you have the server send invoices nightly, you may want to set those emails as EmailType = 'Invoice'. In the Back Office (/admin) website you can see Email History and filter by the Email Type which uses a drop list from the wtkLookups data table with LookupType = 'EmailType'. You can see and edit this code in /admin/emailHistory.php

If you are setting the EmailType data and it is related to a specific table that you are tracking, you may also want to save the `UID` for the associated row of that table in the OtherUID column. For example, if you are generating invoices and sending them nightly, you can put the `Invoice`.`UID` value in this OtherUID and then later you can track via the data exactly which email was sent regarding the invoice and see when it was delivered and whether it was opened.

emails.txt · Last modified: 2022/09/04 22:40 by wtkadmin