Wizard’s Toolkit Documentation

Email.php

This contains all Wizard’s Toolkit functions that involve emailing.

All rights reserved.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tags
author
Programming Labs
license
All rights reserved
version
2.0

Table of Contents

wtkSendMail()  : bool
Primary function to call to send emails.
wtkPostmarkApp()  : bool
Called from wtkSendMail, this uses PostmarkApp to send emails.
wtkSendPHPMail()  : bool
Called from wtkSendMail, this uses PHPMailer to send emails.
wtkSaveEmailSent()  : mixed
wtkNotifyViaEmailPlain()  : void
One-line method of sending an email <strong>without</strong> any email HTML template.
wtkNotifyViaEmail()  : void
One-line method of sending an email using an email HTML template.

Functions

wtkSendMail()

Primary function to call to send emails.

wtkSendMail( array<string|int, mixed>  $fncEmailArray [, array<string|int, mixed>  $fncSaveArray = [] ][, array<string|int, mixed>  $fncAttachments = '' ] , string  $fncDebugLevel) : bool

If second parameter is passed then it will also save email information into wtkEmailsSent data table.

Example call includes defining Email Array and optional Save Array like:
$pgMailArray = array(
'ToAddress' => $pgToEmail,
'ToName' => $pgUserName,
'Subject' => $pgSubject,
'Body' => $pgBody
);

$pgSaveArray = array (
'FromUID' => 0,
'EmailUID' => $pgEmailUID,
'ToUID' => $gloUserUID
);

if (wtkSendMail($pgMailArray, $pgSaveArray)):
// show success message
endif;

Parameters
$fncEmailArray : array<string|int, mixed>
$fncSaveArray : array<string|int, mixed> = []
$fncAttachments : array<string|int, mixed> = ''

defaults to blank

$fncDebugLevel : string

defaults to 0

Tags
global

string $gloEmailMethod

global

string $gloTechSupport

global

string $gloDbConnection If not 'Live' then changes To address to $gloTechSupport and prepends 'TST: ' to subject

global

string $gloWebBaseURL replaces @website@ token

global

string $gloCoName replaces @CompanyName@ in both Subject and Body

uses
function

wtkSendPHPMail or wtkPostmarkApp depending on $gloEmailMethod value

Return values
bool

true if succeeds, false if email fails

wtkPostmarkApp()

Called from wtkSendMail, this uses PostmarkApp to send emails.

wtkPostmarkApp(array<string|int, mixed> $fncEmailArray, array<string|int, mixed> $fncSaveArray[, string $fncAttachments = '' ]) : bool

If second parameter is passed then it will also save email information into wtkEmailsSent data table. This uses curl method of calling PostmarkApp.

Parameters
$fncEmailArray : array<string|int, mixed>
$fncSaveArray : array<string|int, mixed>
$fncAttachments : string = ''

defaults to blank

Tags
global

string $gloPostmarkToken defined in wtk/wtkServerInfo.php

global

string $gloEmailFromAddress will be used as the From email address; must be assigned in PostmarkApp

uses
function

wtkSaveEmailSent to save email data if $fncSaveArray filled

link
https://postmarkapp.com/developer/user-guide/send-email-with-api/send-a-single-email
Return values
bool

true if succeeds, false if email fails

wtkSendPHPMail()

Called from wtkSendMail, this uses PHPMailer to send emails.

wtkSendPHPMail( array<string|int, mixed>  $fncEmailArray[, array<string|int, mixed>  $fncSaveArray = [] ] [, string  $fncAttachments = '' ] , string  $fncDebugLevel) : bool

If second parameter is passed then it will also save email information into wtkEmailsSent data table. This uses curl method of calling PostmarkApp.

Parameters
$fncEmailArray : array<string|int, mixed>
$fncSaveArray : array<string|int, mixed> = []
$fncAttachments : string = ''

defaults to blank

$fncDebugLevel : string

defaults to 0

Tags
global

string $gloEmailFromAddress will be used as the From email address; must be assigned in PostmarkApp

global

string $gloWebBaseURL used for unsubscribe feature

global

string $gloEmailHost all these global variables are defined in wtk/wtkServerInfo.php

global

string $gloEmailMethod

global

string $gloEmailPort

global

string $gloEmailSMTPAuth

global

string $gloEmailFromAddress

global

string $gloEmailPassword

uses
function

wtkSaveEmailSent to save email data if $fncSaveArray filled

link
https://postmarkapp.com/developer/user-guide/send-email-with-api/send-a-single-email
Return values
boolean

true if succeeds, false if email fails

wtkSaveEmailSent()

wtkSaveEmailSent( mixed  $fncSqlFilter , mixed  $fncSaveArray) : mixed

This is called by wtkSendPHPMail and wtkPostmarkApp to log the email into the wtkEmailsSent data table.

Parameters
$fncSqlFilter : mixed
$fncSaveArray : mixed
Return values
mixed

wtkNotifyViaEmailPlain()

One-line method of sending an email <strong>without</strong> any email HTML template.

wtkNotifyViaEmailPlain ( string  $fncSubject , string  $fncMessage [, string  $fncToEmail = '' ][, array<string|int, mixed>  $fncSaveArray = [] ][, string  $fncCC = '' ]) : void

This defaults to sending email to $gloTechSupport definied in wtkServerInfo.php but you can pass both a To and a CC email

Parameters
fncSubject : string
Subject of email.
fncMessage : string
Body of email - this can have HTML in it.
fncToEmail : string
The email address to send to. If this is blank then will send to $gloTechSupport.
fncSaveArray : array<string|int, mixed> = []
This will save additional information into the wtkEmailsSent data table.
$fncCC : string = ''
  • email address to CC if desired
Return values
void

wtkNotifyViaEmail()

One-line method of sending an email using an email HTML template.

wtkNotifyViaEmail( string  $fncSubject , string  $fncMessage [, string  $fncToEmail = '' ] [, array<string|int, mixed>  $fncSaveArray = [] ] [, string  $fncCC = '' ] [, string  $fncTemplate = 'emailDark.htm' ][, string  $fncReplyTo = '' ] [, string  $fncAddNL2BR = 'Y' ] ) : void

This sends email using HTML template, adding log to database and making so will know when/if email is opened. It defaults to sending email to $gloTechSupport defined in wtkServerInfo.php but you can pass both a To and a CC email address.

Parameters
$fncSubject : string
$fncMessage : string
  • body of email
$fncToEmail : string = ''

if blank then $gloTechSupport will be used

$fncSaveArray : array<string|int, mixed> = []
$fncCC : string = ''

email address to CC if desired

$fncTemplate : string = 'emailDark.htm'

what HTML email template you want to use

$fncReplyTo : string = ''

the email addresss to have as the ReplyTo

$fncAddNL2BR : string = 'Y'

defaults to 'Y'; if set to 'Y' then does nl2br() on body of message

Tags
global

string $gloDarkLight if $fncTemplate is not set will default to 'email' . $gloDarkLight . '.htm'

Return values
boolean — returns true if email succeeded and false if email failed. If failed, check wtkErrorLog for details.

Search results