mirror of
https://github.com/Karaka-Management/Developer-Guide.git
synced 2026-01-11 20:38:42 +00:00
improve text
This commit is contained in:
parent
9b6da214e6
commit
37d020af28
|
|
@ -36,7 +36,7 @@ It is recommended to create the translations in a spreadsheet software and expor
|
|||
|
||||
Afterwards you can import the modified csv file in the OMS exchange which will create the language files based on this file.
|
||||
|
||||
> Please note that the csv must be `;` deliminated and `"` escaped.
|
||||
> Please note that the csv must be **;** deliminated and **"** escaped.
|
||||
|
||||
## Import/Export
|
||||
|
||||
|
|
|
|||
54
concepts/tables.md
Normal file
54
concepts/tables.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# Tables/Data Lists
|
||||
|
||||
Tables/data lists are used across all of the application. For this reason filtering, sorting and extracting data is a integral part of the application.
|
||||
|
||||
## Sort Tables/Data Lists
|
||||
|
||||
The goal is to provide users with the option to sort data freely according to their needs. This includes sorting tables/data lists based on multiple (in many cases even all) columns.
|
||||
|
||||
For performance reasons most data is sorted without the `offset` sql keyword.
|
||||
|
||||
If a table/data list is sorted by another column than the primary field it will use the primary field as secondary descending sort option. The reason for this is that in most situations users want to see the newest elements first.
|
||||
|
||||
Url parameters:
|
||||
|
||||
* `element` = which element is getting sorted. Only one table/data list on a page can be sorted.
|
||||
* `id` = base id for the pagination. This id is most of the time the primary field of the model
|
||||
* `ptype` = pagination type.
|
||||
* This parameter can be `p` for previous page or `n` for next page and defines how the base id should be interpreted.
|
||||
* `p` means that elements to the **left/above** of `id` should be shown
|
||||
* `n` means that elements to the **right/below** of `id` should be shown
|
||||
* `sort_by` defines the column which is used to sort the data
|
||||
* `sort_order` defines what **left/above** and **right/below** mean
|
||||
* `ASC` means ascending and therfore defines **left/above** as smaller elements and **right/below** as larger elements
|
||||
* `DESC` means descending and therfore defines **left/above** as larger elements and **right/below** as smaller elements
|
||||
* `subid` defines the id of the `sort_by` column IFF `sort_by` is not the primary field.
|
||||
|
||||
> The maximum amount of elements returned depend on the defined limit.
|
||||
|
||||
An example sort query may look like this:
|
||||
|
||||
```html
|
||||
?sort_by=module&sort_order=DESC&id=123&subid=Backend&ptype=n
|
||||
```
|
||||
|
||||
This returns a data list with:
|
||||
|
||||
* data sorted by the module parameter
|
||||
* the module parameter is sorted descending (Z -> A)
|
||||
* the module parameter should start with "Backend" or smaller
|
||||
* only data with an ID smaller than 123 should be returned (**no** data with module parameter "Backend" and id 124 or larger should be returned)
|
||||
|
||||
## Filter Tables/Data Lists
|
||||
|
||||
## Limit Data
|
||||
|
||||
If no limit is defined tables/data lists often return up to 25 or 50 elements. User defined limits are mostly done by providing the `limit` parameter. A limit of 0 returns all results (this may be blocked for frontend output)
|
||||
|
||||
Example
|
||||
|
||||
```html
|
||||
?limit=75
|
||||
```
|
||||
|
||||
## Export Data
|
||||
|
|
@ -2,23 +2,27 @@
|
|||
|
||||
The following application is a minimal sample in order to show how it's possible to set it up. Please note that for simplicity purposes many framework features and architectural aspects are omitted.
|
||||
|
||||
## .htaccess
|
||||
|
||||
The .htaccess file can be used to enable URL rewriting, file compression for css, js files, caching, and much more. In this sample application we will only do the bare minimum by enabling URL rewriting.
|
||||
|
||||
```txt
|
||||
# .htaccess
|
||||
# enable URL rewriting
|
||||
<ifmodule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteCond %{HTTP:Accept-encoding} gzip
|
||||
RewriteCond %{REQUEST_FILENAME} \.(js|css)$
|
||||
RewriteCond %{REQUEST_FILENAME}.gz -f
|
||||
RewriteRule ^(.*)$ $1.gz [QSA,L]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ /?{QUERY_STRING} [QSA]
|
||||
RewriteCond %{HTTPS} !on
|
||||
RewriteCond %{HTTP_HOST} !^(127\.0\.0)|(192\.)|(172\.)
|
||||
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
|
||||
</ifmodule>
|
||||
```
|
||||
|
||||
## index.php
|
||||
|
||||
In the index file the application gets initialized and executed.
|
||||
|
||||
```php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
|
|
@ -35,6 +39,12 @@ echo $App->run(); // outputs the application response
|
|||
\ob_end_flush();
|
||||
```
|
||||
|
||||
We use output buffering `\ob_start()` and `\ob_end_flush()` which allows the application to internally modify the response before it gets returned to the user.
|
||||
|
||||
## Application.php
|
||||
|
||||
The application file is responsible for initializing the application resources, handling the request and response population (see Router and Dispatcher) as well as rendering the main view. Another task which is often performed in this file is the user authentication.
|
||||
|
||||
```php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
|
|
@ -143,6 +153,10 @@ class Application extends ApplicationAbstract
|
|||
}
|
||||
```
|
||||
|
||||
## Routes.php
|
||||
|
||||
The routes file contains the routing information. which is responsible for matching URLs to application end-points.
|
||||
|
||||
```php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
|
|
@ -181,6 +195,10 @@ return [
|
|||
];
|
||||
```
|
||||
|
||||
## index.tpl.php
|
||||
|
||||
The index template is the main template which is used to render all frontend responses from the dispatcher to the user. The layout is completely in the hands of the developer and designer.
|
||||
|
||||
```php
|
||||
<!-- app/tpl/index.tpl.php Main template -->
|
||||
<html>
|
||||
|
|
@ -200,11 +218,17 @@ return [
|
|||
</html>
|
||||
```
|
||||
|
||||
The `$dispatch` date is populated in the `Application.php` an can be used in this template. Often is is just one element but in some cases multiple endpoints get matched to a URL and provide content for the user.
|
||||
|
||||
## Controller.php
|
||||
|
||||
A controller file defines the end-point functionality. In this file the response content is generated incl. the date collection for the response. Usually there are two types of controllers, one is a UI controller which is responsible for generating UI content and the other is a API controller which is used to handle API logic (e.g. handling form data such as creating/updating new models).
|
||||
|
||||
```php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
// app/controller/TestController.php
|
||||
// Sample controller which is referenced in the routes
|
||||
// Sample (UI) controller which is referenced in the routes
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
|
|
@ -260,6 +284,10 @@ class TestController
|
|||
}
|
||||
```
|
||||
|
||||
## View.php
|
||||
|
||||
A view is responsible for handling and rendering template data. Some business logic doesn't belong in the controller but rather to a specific view (i.e. how to render a user name).
|
||||
|
||||
```php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
|
|
@ -280,6 +308,10 @@ class TestView extends View
|
|||
}
|
||||
```
|
||||
|
||||
## Templates
|
||||
|
||||
Templates contain the actual content which should get shown/returned to the user. We already learned about the `index.tpl.php`. These template files are returned from the controller as part of a view and then rendered in the `index.tpl.php` file. Inside of a template you can access the view data and view logic and helper functions defined in the view.
|
||||
|
||||
```html
|
||||
<!-- app/tpl/welcome.tpl.php This is shown in the index.tpl.php -->
|
||||
<div><?= 'Hello ' . $this->renderBold('beautiful') . ' World!' ?></div>
|
||||
|
|
@ -293,4 +325,5 @@ class TestView extends View
|
|||
```html
|
||||
<!-- app/tpl/overwritten.tpl.php This becomes the new main template -->
|
||||
<div>The main template got overwritten!</div>
|
||||
```
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -28,3 +28,4 @@ header ('Content-type: image/png');
|
|||
imagepng($c128b);
|
||||
imagedestroy($c128b);
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +1,159 @@
|
|||
# Logging
|
||||
|
||||
The core provides two different logging outputs, one is a file output for low level logging such as exceptions, warnings and errors as well as a database logging for activity logging and higher level problems.
|
||||
The core provides two different logging outputs, one is server side file logging for exceptions, warnings etc. and the other one is for front end logging.
|
||||
|
||||
Both logging implementations provide the following logging functions for the different logging levels.
|
||||
- [Server side file logging](#server-side-file-logging)
|
||||
- [Client side logging](#client-side-logging)
|
||||
|
||||
* `emergency()`
|
||||
* `alert()`
|
||||
* `critical()`
|
||||
* `error()`
|
||||
* `notice()`
|
||||
* `info()`
|
||||
* `debug()`
|
||||
* `console()`
|
||||
* `log()`
|
||||
## Server side file logging
|
||||
|
||||
All functions take at least two parameters where one is the message and the other one is the optional context that should be injected into the message.
|
||||
The file logging should only be used for database and application problems. The file logging is part of the framework and is always available. The logging class implements the [LoggerInterface](https://github.com/Karaka-Management/phpOMS/blob/develop/Log/LoggerInterface.php).
|
||||
|
||||
### Initialization
|
||||
|
||||
```php
|
||||
$log->error(FileLogger::MSG_FULL, ['message' => 'Log me!']);
|
||||
use phpOMS\Log\FileLogger;
|
||||
|
||||
$log = new FileLogger(string $lpath = '', bool $verbose = false);
|
||||
|
||||
// or
|
||||
$log = FileLogger::getInstance(string $lpath = '', bool $verbose = false);
|
||||
|
||||
// or accessable through the application object
|
||||
$app->logger;
|
||||
```
|
||||
|
||||
## File Logging
|
||||
* **(string) $lpath**: Path to the logging *directory* or logging *file*. If the path is a directory the logger will automatically create log files in the format $lpath/Y-m-d.
|
||||
* **(bool) $verbose**: If true also outputs the logs to the current output buffer.
|
||||
|
||||
The file logging should only be used for database and application problems. The file logging is part of the framework and is always available. The file logger implements the singleton pattern and can be acquired by calling the `getInstance()` function.
|
||||
### Logging
|
||||
|
||||
```php
|
||||
$log = FileLogger::getInstance('logging/path', false);
|
||||
$log->emergency(string $message, array $context = []);
|
||||
$log->alert(string $message, array $context = []);
|
||||
$log->critical(string $message, array $context = []);
|
||||
$log->error(string $message, array $context = []);
|
||||
$log->warning(string $message, array $context = []);
|
||||
$log->notice(string $message, array $context = []);
|
||||
$log->info(string $message, array $context = []);
|
||||
$log->debug(string $message, array $context = []);
|
||||
$log->log(string $level, string $message, array $context = []);
|
||||
```
|
||||
|
||||
Once initialized these two parameters are no longer required. The file logger will create a log file in the provided directory in the format `{Y-m-d}.log`.
|
||||
* **(string) $message**: Message or message format used for logging.
|
||||
* **(array) $context**: Context used to populate the message.
|
||||
|
||||
## Client Side Logging
|
||||
#### Example
|
||||
|
||||
On the client side a logger is also implemented providing the same functions as described above. The only difference is that this logger can remote log messages. Logging messages will get forwarded to the server which will log these messages with the file logger.
|
||||
```php
|
||||
$log->alert(FileLogger::MSG_BACKTRACE, ['message' => 'Test log.']);
|
||||
// Output: "2022-01-01 08:23:45"; "alert"; "127.0.0.1"; "Test log."; ...
|
||||
|
||||
$log->alert("Alert log.");
|
||||
// Output: Alert log.
|
||||
|
||||
$log->log(FileLogger::MSG_BACKTRACE, ['message' => 'Test log.'], \phpOMS\Log\LogLevel::WARNING);
|
||||
// Output: "2022-01-01 08:23:45"; "warning"; "127.0.0.1"; "Test log."; ...
|
||||
```
|
||||
|
||||
#### Default messages
|
||||
|
||||
```php
|
||||
FileLogger::MSG_BACKTRACE = '{datetime}; {level}; {ip}; {message}; {backtrace}';
|
||||
FileLogger::MSG_FULL = '{datetime}; {level}; {ip}; {line}; {version}; {os}; {path}; {message}; {file}; {backtrace}';
|
||||
FileLogger::MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};';
|
||||
```
|
||||
|
||||
The names in the *{}* brackets are used as identifiers in the context array.
|
||||
|
||||
The following identifiers have special meaning and are automatically populated in the logger:
|
||||
|
||||
* **backtrace**: Application backtrace
|
||||
* **datetime**: Current datetime
|
||||
* **level**: Populated based on the log function that got used (see [LogLevel](https://github.com/Karaka-Management/phpOMS/blob/develop/Log/LogLevel.php))
|
||||
* **path**: `$_SERVER['REQUEST_URI']`
|
||||
* **ip**: `$_SERVER['REMOTE_ADDR']`
|
||||
* **version**: `\PHP_VERSION`
|
||||
* **os**: `\PHP_OS`
|
||||
|
||||
#### References
|
||||
|
||||
* [Tests](https://github.com/Karaka-Management/phpOMS/blob/develop/tests/Log/FileLoggerTest.php)
|
||||
* [Implementation](https://github.com/Karaka-Management/phpOMS/blob/develop/Log/FileLogger.php)
|
||||
|
||||
## Client side logging
|
||||
|
||||
On the client side a logger is also implemented providing the same functions as described above. The only difference is that this logger can remote log messages.
|
||||
|
||||
### Initialization
|
||||
|
||||
```js
|
||||
let log = jsOMS.Log.Logger.getInstance(true, false, true);
|
||||
import { Logger } from './jsOMS/Log/Logger.js';
|
||||
|
||||
let log = new Logger(bool verbose = true, bool ui = false, bool remote = true);
|
||||
|
||||
// or
|
||||
let log = Logger.getInstance(bool verbose = true, bool ui = false, bool remote = true);
|
||||
|
||||
// or accessable through the window or application object
|
||||
window.logger;
|
||||
window.omsApp.logger;
|
||||
```
|
||||
|
||||
* The first parameter defines if the log output will done in the console
|
||||
* The second parameter defines if the log output should be done as notification
|
||||
* The thrid parameter defines if the log output should be send to the backend
|
||||
* **verbose**: Defines if the log output will done in the console as well
|
||||
* **ui**: Defines if the log output should be done as notification in the UI (uses the [Notification API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API))
|
||||
* **remote**: Defines if the log output should be send to the backend (log endpoint is `/{lang}/api/log`)
|
||||
|
||||
### Logging
|
||||
|
||||
```js
|
||||
log.emergency(string $message, object $context = {});
|
||||
log.alert(string $message, object $context = {});
|
||||
log.critical(string $message, object $context = {});
|
||||
log.error(string $message, object $context = {});
|
||||
log.warning(string $message, object $context = {});
|
||||
log.notice(string $message, object $context = {});
|
||||
log.info(string $message, object $context = {});
|
||||
log.debug(string $message, object $context = {});
|
||||
log.console(string $message, object $context = {});
|
||||
log.log(string $level, string $message, object $context = {});
|
||||
```
|
||||
|
||||
* **(string) message**: Message or message format used for logging.
|
||||
* **(object) context**: Context used to populate the message.
|
||||
|
||||
#### Example
|
||||
|
||||
```js
|
||||
log.alert(Logger.MSG_FULL, {'message': 'Test log.'});
|
||||
// Output: "2022-01-01 08:23:45"; "alert"; "1.0.0"; "linux"; chrome"; "http://127.0.0.1"; Test log.";
|
||||
|
||||
log.alert("Alert log.");
|
||||
// Output: Alert log.
|
||||
|
||||
log.log(Logger.MSG_FULL, {'message': 'Test log.'}, LogLevel.WARNING);
|
||||
// Output: "2022-01-01 08:23:45"; "warning"; "1.0.0"; "linux"; chrome"; "http://127.0.0.1"; Test log.";
|
||||
```
|
||||
|
||||
#### Default messages
|
||||
|
||||
```js
|
||||
Logger.MSG_FULL = '{datetime}; {level}; {version}; {os}; {browser}; {path}; {message}';
|
||||
```
|
||||
|
||||
The names in the *{}* brackets are used as identifiers in the context array.
|
||||
|
||||
The following identifiers have special meaning and are automatically populated in the logger:
|
||||
|
||||
* **backtrace**: Application backtrace
|
||||
* **datetime**: Current datetime
|
||||
* **level**: Populated based on the log function that got used (see [LogLevel](https://github.com/Karaka-Management/jsOMS/blob/develop/Log/LogLevel.js))
|
||||
* **os**: Browser type (see [OSType](https://github.com/Karaka-Management/jsOMS/blob/develop/System/OSType.js))
|
||||
* **browser**: Browser type (see [BrowserType](https://github.com/Karaka-Management/jsOMS/blob/develop/System/BrowserType.js))
|
||||
* **path**: window.location.href
|
||||
* **version**: 1.0.0
|
||||
|
||||
#### References
|
||||
|
||||
* [Tests](https://github.com/Karaka-Management/jsOMS/blob/develop/tests/Log/LoggerTest.js)
|
||||
* [Implementation](https://github.com/Karaka-Management/jsOMS/blob/develop/Log/Logger.js)
|
||||
|
|
|
|||
225
services/mail.md
225
services/mail.md
|
|
@ -0,0 +1,225 @@
|
|||
# Mail
|
||||
|
||||
Sending and receiving emails is possible with the included mail classes. The mailing is implemented in such a way that you can create emails which you then can pass to a mail handler which sends the mails.
|
||||
|
||||
## Sending
|
||||
|
||||
For email sending external mail servers are recommended, especially for advertisements, mailing lists etc. since a self hosted mailing server is very likely to get blacklisted by email services.
|
||||
|
||||
### Mail handler
|
||||
|
||||
#### Handler
|
||||
|
||||
Available mail handlers are:
|
||||
|
||||
* IMAP
|
||||
* POP3
|
||||
|
||||
##### IMAP Connection
|
||||
|
||||
```php
|
||||
// Define mailer
|
||||
$handler = new Imap('testuser', 'testuser', 143);
|
||||
$handler->host = '127.0.0.1';
|
||||
$handler->flags = '/imap/notls/norsh/novalidate-cert';
|
||||
|
||||
// ...
|
||||
|
||||
// Send email
|
||||
$handler->send($mail);
|
||||
```
|
||||
|
||||
##### POP3 Connection
|
||||
|
||||
```php
|
||||
// Define mailer
|
||||
$handler = new Pop3('testuser', 'testuser', 110);
|
||||
$handler->host = '127.0.0.1';
|
||||
$handler->flags = '/pop3/notls';
|
||||
|
||||
// ...
|
||||
|
||||
// Send email
|
||||
$handler->send($mail);
|
||||
```
|
||||
|
||||
#### Software
|
||||
|
||||
For sending emails you can chose between the following mailing programs depending on your server setup:
|
||||
|
||||
* Sendmail
|
||||
* Mail
|
||||
* Smtp
|
||||
|
||||
|
||||
```php
|
||||
// Mail
|
||||
$handler->setMailer(SubmitType::MAIL);
|
||||
|
||||
// SMTP
|
||||
$handler->setMailer(SubmitType::SMTP);
|
||||
$handler->useAutoTLS = false;
|
||||
|
||||
// Sendmail
|
||||
$handler->setMailer(SubmitType::SENDMAIL);
|
||||
```
|
||||
|
||||
### Confirmation Address
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->confirmationAddress = 'test1@karaka.email';
|
||||
```
|
||||
|
||||
### From, To, CC & BCC
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->setFrom('test1@karaka.email', 'Dennis Eichhorn');
|
||||
$mail->addTo('test@karaka.email', 'Dennis Eichhorn');
|
||||
$mail->addCC('test2@karaka.email', 'Dennis Eichhorn');
|
||||
$mail->addBCC('test3@karaka.email', 'Dennis Eichhorn');
|
||||
```
|
||||
|
||||
### Reply
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->addReplyTo('test4@karaka.email', 'Dennis Eichhorn');
|
||||
```
|
||||
|
||||
### Subject
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->subject = 'Test subject';
|
||||
```
|
||||
### Body
|
||||
|
||||
#### Plain
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->body = 'Body';
|
||||
```
|
||||
|
||||
#### Html
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$message = \file_get_contents(__DIR__ . '/files/utf8.html');
|
||||
$mail->charset = CharsetType::UTF_8;
|
||||
$mail->body = '';
|
||||
$mail->bodyAlt = '';
|
||||
|
||||
$mail->setHtml(true);
|
||||
$mail->msgHTML($message, __DIR__ . '/files');
|
||||
```
|
||||
|
||||
#### Calendar
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->body = 'Ical test';
|
||||
$mail->altBody = 'Ical test';
|
||||
$mail->ical = 'BEGIN:VCALENDAR'
|
||||
. "\r\nVERSION:2.0"
|
||||
. "\r\nPRODID:-//phpOMS//Karaka Calendar//EN"
|
||||
. "CONTENT"
|
||||
. "\r\nCALSCALE:GREGORIAN"
|
||||
. "\r\nX-MICROSOFT-CALSCALE:GREGORIAN"
|
||||
. "\r\nBEGIN:VEVENT"
|
||||
. "\r\nUID:201909250755-42825@test"
|
||||
. "\r\nDTSTART;20190930T080000Z"
|
||||
. "\r\nSEQUENCE:2"
|
||||
. "\r\nTRANSP:OPAQUE"
|
||||
. "\r\nSTATUS:CONFIRMED"
|
||||
. "\r\nDTEND:20190930T084500Z"
|
||||
. "\r\nLOCATION:[London] London Eye"
|
||||
. "\r\nSUMMARY:Test ICal method"
|
||||
. "\r\nATTENDEE;CN=Attendee, Test;ROLE=OPT-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP="
|
||||
. "\r\n TRUE:MAILTO:attendee-test@example.com"
|
||||
. "\r\nCLASS:PUBLIC"
|
||||
. "\r\nDESCRIPTION:Some plain text"
|
||||
. "\r\nORGANIZER;CN=\"Example, Test\":MAILTO:test@example.com"
|
||||
. "\r\nDTSTAMP:20190925T075546Z"
|
||||
. "\r\nCREATED:20190925T075709Z"
|
||||
. "\r\nLAST-MODIFIED:20190925T075546Z"
|
||||
. "\r\nEND:VEVENT"
|
||||
. "\r\nEND:VCALENDAR";
|
||||
|
||||
```
|
||||
|
||||
### Attachments
|
||||
|
||||
#### External file
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->addAttachment(__DIR__ . '/files/logo.png', 'logo');
|
||||
```
|
||||
#### Inline
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->setHtml(true);
|
||||
$mail->msgHTML("<img alt=\"image\" src=\"cid:cid1\">");
|
||||
$mail->addEmbeddedImage(__DIR__ . '/files/logo.png', 'cid1');
|
||||
```
|
||||
|
||||
#### String files
|
||||
|
||||
```php
|
||||
$mail = new Email();
|
||||
$mail->addStringAttachment('String content', 'string_content_file.txt');
|
||||
$mail->addStringEmbeddedImage(\file_get_contents(__DIR__ . '/files/logo.png'), 'cid2');
|
||||
```
|
||||
|
||||
## Receiving
|
||||
|
||||
### Handler
|
||||
|
||||
#### IMAP Connection
|
||||
|
||||
```php
|
||||
// Define mailer
|
||||
$handler = new Imap('testuser', 'testuser', 143);
|
||||
$handler->host = '127.0.0.1';
|
||||
$handler->flags = '/imap/notls/norsh/novalidate-cert';
|
||||
```
|
||||
|
||||
#### POP3 Connection
|
||||
|
||||
```php
|
||||
// Define mailer
|
||||
$handler = new Pop3('testuser', 'testuser', 110);
|
||||
$handler->host = '127.0.0.1';
|
||||
$handler->flags = '/pop3/notls';
|
||||
```
|
||||
|
||||
### Mailboxes
|
||||
|
||||
#### List, Create, Rename, Delete
|
||||
|
||||
```php
|
||||
$handler->getBoxes();
|
||||
$handler->createBox('TestBox');
|
||||
$handler->renameBox('TestBox', 'NewTestBox');
|
||||
$handler->deleteBox('NewTestBox');
|
||||
```
|
||||
|
||||
#### Info
|
||||
|
||||
```php
|
||||
$handler->getMailboxInfo('INBOX.TestBox');
|
||||
|
||||
$handler->countMail('INBOX.TestBox');
|
||||
$handler->handler->countRecent('INBOX.TestBox');
|
||||
$handler->handler->countUnseen('INBOX.TestBox');
|
||||
```
|
||||
|
||||
#### Mail List
|
||||
|
||||
```php
|
||||
$handler->getHeaders('INBOX')
|
||||
```
|
||||
|
|
@ -29,10 +29,10 @@ or for multiline function parameters
|
|||
|
||||
```php
|
||||
function(
|
||||
$para1,
|
||||
$para2,
|
||||
$para3,
|
||||
$para4
|
||||
string $para1,
|
||||
int $para2,
|
||||
bool $para3,
|
||||
array $para4
|
||||
) : int
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user