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
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
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
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
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