× " id="k8-modal-content" alt="modal">

PHP Mail

PHP-Mail

Most Web-Server offer an email function. But offen the desired sender Email is not configured on the Web Server. K8 Web Kit supports the following 2 email systems:

  • email by the Web server
  • email by PHPMailer and an external email server

Use cases

  • gbSendContact()
  • gbsendActivation()
  • gbSendPwd()

Basic Configuration

config/_init.php

The default domain_emailmode is set to "1: email by PHPmailer". Please fill out your email configuration in the _init.php.

If the domain_emailmode is set to "0: email by server": please look to your Server Email Configuration and check the configuration.

The default domain_testemail can be used for several user as test. Please regard that "Send Password" is not working well in this case.

domain_email allows to configure:

  • activate, Activation email
  • sendPwd, Send password email

For both:

  • subject
  • content

can be declared. The content supports HTML-emails.

The template can be used for further necessary emails.

PHPMailer

Configuration

config/_init.php

The default domain_emailmode is set to "1: PHPMailer". Please continue with the configuration for your email server. For example for a google email server it is important to configure an App-Password for third party access (description of App Password configuration).

More information to:

<projectpath>/_init.json

This is the same definitiion written in JSON format.

Send email

JavaScript

domain_emailrights

  • 0: no emails
  • 1: to logged in user only (default)
  • 2: logged in to every one
  • 3: role: 32
  • 4: own email configuration (future)

Parameters:

  • to
  • cc
  • bcc
  • subject
  • message: this is the whole email body
  • content: uses the template

PHP

If you want to use PHPMailer for own emails even by your customer, you can declare PHPMailer like this and transfer the customer mail server access data.

Email templates

PHP-Mail

Email templates allow you to conveniently create and format templates.

Action

The name for the email, should be the action, which it's used for.

Language

You can define different languages for one action.

Bcc

if necessary send the email to blind copy.

Content

The Content can be formated with this editor (tinymce). Placeholders can be used like this {{placeholder}}. By sending the email, they are exchanged for the value of the data record. The content is inserted in the global email template.

Message

The message is equivalent to the content. This message is send as email body. It should have also a signature.

Images

Images can be uploaded by the image icon, "Upload". The image can be resized by the image handler. It's saved in the upload folder and the complete url is linked in the image tag.

The ediors above use absolut path with (datadefinition.masterdata.seofriendly: true).

Load all templates

Your datadefintion :

The file: {{datadefID}}_head_include.php is included. This includes the email templates into your web site.

the include for php:

The variable data_emailtemplates is declared in JavaScript. It's an array with all defined templates.

Use the template

JavaScript excerp of callback cbmenuleft of reclamationapprovals:

Process

  • statustext: prepare the status text
  • dat_emailtemplates: filter the template reclamation_approval from array
  • prepare the data for the email, dat_email:
    • to
    • bcc
    • subject
    • message
  • command PHP to send the email
  • set emailsend in the recclamationapprovals
  • set recclamationapprovals