Commit 345454f4 authored by Elias Villiger's avatar Elias Villiger
Browse files

Merge branch 'master' into 5414-checktype-auto

parents 3aa4a25d 1835d381
......@@ -5523,10 +5523,19 @@ Column: _sendmail
t:<TO:email[,email]>|f:<FROM:email>|s:<subject>|b:<body>
[|c:<CC:email[,email]]>[|B:<BCC:email[,email]]>[|r:<REPLY-TO:email>]
[|a:<flag autosubmit: on /off>][|g:<grid>][|x:<xId>][|y:<xId2>][|z:<xId3>]
[|A:<flag autosubmit: on/off>][|g:<grId>][|x:<xId>][|y:<xId2>][|z:<xId3>][|h:<mail header>]
[|e:<subject encode: encode/decode/none>][E:<body encode: encode/decode/none>]
[|C][d:<filename of the attachment>][|F:<file to attach>][|u:<url>][|p:<T3 uri>]
Send text emails. Every mail will be logged in the table `mailLog`. Attachments are supported.
The following parameters can also be written as complete words for ease of use:
::
to:<email[,email]>|from:<email>|subject:<subject>|body:<body>
[|cc:<email[,email]]>[|bcc:<email[,email]]>[|reply-to:<email>]
[|autosubmit:<on/off>][|grid:<grid>][|xid:<xId>][|xid2:<xId2>][|xid3:<xId3>][|header:<mail header>]
Send emails. Every mail will be logged in the table `mailLog`. Attachments are supported.
**Syntax**
......@@ -5537,50 +5546,63 @@ Send text emails. Every mail will be logged in the table `mailLog`. Attachments
..
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
|**Token** | **Parameter** |**Description** |**Required**|
+==========+========================================+==================================================================================================+============+
+============+========================================+==================================================================================================+============+
| f | email |**FROM**: Sender of the email. Optional: 'realname <john@doe.com>' | yes |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| from | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| t | email[,email] |**TO**: Comma separated list of receiver email addresses. Optional: `realname <john@doe.com>` | yes |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| to | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| c | email[,email] |**CC**: Comma separated list of receiver email addresses. Optional: 'realname <john@doe.com>' | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| cc | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| B | email[,email] |**BCC**: Comma separated list of receiver email addresses. Optional: 'realname <john@doe.com>' | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| bcc | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| r | REPLY-TO:email |**Reply-to**: Email address to reply to (if different from sender) | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| reply-to | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| s | Subject |**Subject**: Subject of the email | yes |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| subject | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| b | Body |**Body**: Message - see also: `html-formatting`_ | yes |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| body | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| h | Mail header |**Custom mail header**: Separate multiple header with \\r\\n | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| header | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| F | Attach file |**Attachment**: File to attach to the mail. Repeatable. | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| u | Attach created PDF of a given URL |**Attachment**: Convert the given URL to a PDF and attach it the mail. Repeatable. | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| p | Attach created PDF of a given T3 URL |**Attachment**: Convert the given URL to a PDF and attach it the mail. Repeatable. | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| d | Filename of the attachment |**Attachment**: Useful for URL to PDF converted attachments. Repeatable. | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| C | Concat multiple F|p|u| together |**Attachment**: All following (until the next 'C') 'F|p|u' concatenated to one attachment. | |
| | | Repeatable. | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| A | flagAutoSubmit 'on' / 'off' |If 'on' (default), add mail header 'Auto-Submitted: auto-send' - suppress OoO replies | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| autosubmit | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| g | grId |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| grid | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| x | xId |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| xid | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| y | xId2 |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| xid2 | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| z | xId3 |Will be copied to the mailLog record. Helps to setup specific logfile queries | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| xid3 | | | yes |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| e | encode|decode|none |**Subject**: will be htmlspecialchar() encoded, decoded (default) or none (untouched) | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
| E | encode|decode|none |**Body**: will be htmlspecialchar() encoded, decoded (default) or none (untouched). | |
+----------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
* **e|E**: By default, QFQ stores values 'htmlspecialchars()' encoded. If such values have to send by email, the html entities are
unwanted. Therefore the default setting for 'subject' und 'body' is to decode the values via 'htmlspecialchars_decode()'.
......
......@@ -3165,7 +3165,7 @@ abstract class AbstractBuildForm {
// $formElement['editor-plugins']='autoresize code'
// $formElement['editor-contextmenu']='link image | cell row column'
$json = $this->getPrefixedElementsAsJSON(FE_EDITOR_PREFIX, $formElement);
$attribute .= Support::doAttribute('data-config', $json, true, ESCAPE_WITH_HTML_QUOTE);
$attribute .= Support::doAttribute('data-config', $json, true);
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE]);
......
......@@ -1110,24 +1110,38 @@ const EXISTING_PATH_FILE_NAME = '_existingPathFileName';
//SENDMAIL
const SENDMAIL_TOKEN_RECEIVER = 't';
const SENDMAIL_TOKEN_RECEIVER_LONG = 'to';
const SENDMAIL_TOKEN_SENDER = 'f';
const SENDMAIL_TOKEN_SENDER_LONG = 'from';
const SENDMAIL_TOKEN_SUBJECT = 's';
const SENDMAIL_TOKEN_SUBJECT_LONG = 'subject';
const SENDMAIL_TOKEN_BODY = 'b';
const SENDMAIL_TOKEN_BODY_LONG = 'body';
const SENDMAIL_TOKEN_REPLY_TO = 'r';
const SENDMAIL_TOKEN_REPLY_TO_LONG = 'reply-to';
const SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT = 'A';
const SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT_LONG = 'autosubmit';
const SENDMAIL_TOKEN_GR_ID = 'g';
const SENDMAIL_TOKEN_GR_ID_LONG = 'grid';
const SENDMAIL_TOKEN_X_ID = 'x';
const SENDMAIL_TOKEN_X_ID_LONG = 'xid';
const SENDMAIL_TOKEN_X_ID2 = 'y';
const SENDMAIL_TOKEN_X_ID2_LONG = 'xid2';
const SENDMAIL_TOKEN_X_ID3 = 'z';
const SENDMAIL_TOKEN_X_ID3_LONG = 'xid3';
const SENDMAIL_TOKEN_HEADER = 'h';
const SENDMAIL_TOKEN_HEADER_LONG = 'header';
const SENDMAIL_TOKEN_SRC = 'S';
const SENDMAIL_TOKEN_SRC_LONG = 'source';
const SENDMAIL_TOKEN_RECEIVER_CC = 'c';
const SENDMAIL_TOKEN_RECEIVER_CC_LONG = 'cc';
const SENDMAIL_TOKEN_RECEIVER_BCC = 'B';
const SENDMAIL_TOKEN_RECEIVER_BCC_LONG = 'bcc';
const SENDMAIL_TOKEN_ATTACHMENT = 'attachment';
const SENDMAIL_TOKEN_ATTACHMENT_FILE = 'F';
const SENDMAIL_TOKEN_ATTACHMENT_FILE_DEPRECATED = 'a'; // since 5.12.17
const SENDMAIL_TOKEN_HEADER = 'h';
const SENDMAIL_TOKEN_X_ID2 = 'y';
const SENDMAIL_TOKEN_X_ID3 = 'z';
const SENDMAIL_TOKEN_SUBJECT_HTML_ENTITY = 'e';
const SENDMAIL_TOKEN_BODY_HTML_ENTITY = 'E';
const SENDMAIL_TOKEN_SRC = 'S';
const SENDMAIL_TOKEN_CONCAT = 'C';
const SENDMAIL_TOKEN_DOWNLOAD_FILENAME = 'd';
......
......@@ -153,10 +153,10 @@ class Support {
* @param bool $flagOmitEmpty
* @param string $modeEscape
*
* @return string correctly fomratted attribute. Space at the end.
* @return string correctly formatted attribute. Space at the end.
* @throws CodeException
*/
public static function doAttribute($type, $value, $flagOmitEmpty = true, $modeEscape = ESCAPE_WITH_BACKSLASH) {
public static function doAttribute($type, $value, $flagOmitEmpty = true, $modeEscape = ESCAPE_WITH_HTML_QUOTE) {
// several attributes might be given as an array - concat to a string
if (is_array($value)) {
......
......@@ -339,7 +339,7 @@ class SendMail {
/**
* Convert a token based sendMail string into an array.
* - Each attachment (single file or mulitple concatenated files) is an array in the array.
* - Each attachment (single file or multiple concatenated files) is an array in the array.
*
* @param string $data E.g.: 't:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John ...'
* @return array
......@@ -355,6 +355,23 @@ class SendMail {
$flagSource = false;
$flagFilename = false;
$convertToShorthandToken = [
SENDMAIL_TOKEN_RECEIVER_LONG => SENDMAIL_TOKEN_RECEIVER,
SENDMAIL_TOKEN_SENDER_LONG => SENDMAIL_TOKEN_SENDER,
SENDMAIL_TOKEN_SUBJECT_LONG => SENDMAIL_TOKEN_SUBJECT,
SENDMAIL_TOKEN_BODY_LONG => SENDMAIL_TOKEN_BODY,
SENDMAIL_TOKEN_RECEIVER_CC_LONG => SENDMAIL_TOKEN_RECEIVER_CC,
SENDMAIL_TOKEN_RECEIVER_BCC_LONG => SENDMAIL_TOKEN_RECEIVER_BCC,
SENDMAIL_TOKEN_REPLY_TO_LONG => SENDMAIL_TOKEN_REPLY_TO,
SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT_LONG => SENDMAIL_TOKEN_FLAG_AUTO_SUBMIT,
SENDMAIL_TOKEN_GR_ID_LONG => SENDMAIL_TOKEN_GR_ID,
SENDMAIL_TOKEN_X_ID_LONG => SENDMAIL_TOKEN_X_ID,
SENDMAIL_TOKEN_X_ID2_LONG => SENDMAIL_TOKEN_X_ID2,
SENDMAIL_TOKEN_X_ID3_LONG => SENDMAIL_TOKEN_X_ID3,
SENDMAIL_TOKEN_HEADER_LONG => SENDMAIL_TOKEN_HEADER,
SENDMAIL_TOKEN_SRC_LONG => SENDMAIL_TOKEN_SRC,
];
$param = explode(PARAM_DELIMITER, $data);
// Iterate over all parameter: use token as key. Collect corresponding attachments arguments in separate array elements
......@@ -364,12 +381,22 @@ class SendMail {
continue;
}
$token = $line[0];
if (strlen($line) > 2 && $line[1] != PARAM_TOKEN_DELIMITER) {
$tokenAndValue = explode(PARAM_TOKEN_DELIMITER, $line, 2);
if (count($tokenAndValue) < 2 && $tokenAndValue[0] !== SENDMAIL_TOKEN_CONCAT) {
throw new UserFormException('Missing token delimiter "' . PARAM_TOKEN_DELIMITER . '" in: ' . $line, ERROR_UNKNOWN_TOKEN);
}
$token = $tokenAndValue[0];
// convert speaking word tokens to shorthand
if (strlen($token) > 1) {
$token = strtolower($token); // speaking word tokens are all lowercase
if (isset($convertToShorthandToken[$token])) {
$token = $convertToShorthandToken[$token];
} else {
throw new UserFormException('Unknown token "' . $token . '" in: ' . $line, ERROR_UNKNOWN_TOKEN);
}
}
// Check for deprecated token.
if ($token == SENDMAIL_TOKEN_ATTACHMENT_FILE_DEPRECATED) {
throw new UserFormException('Sendmail: Option "a:" is deprecated, please use "' . SENDMAIL_TOKEN_ATTACHMENT_FILE . '" instead', ERROR_UNKNOWN_TOKEN);
......@@ -408,7 +435,7 @@ class SendMail {
break;
default:
$args[$token] = substr($line, 2);
$args[$token] = $tokenAndValue[1];
break;
}
}
......
......@@ -30,16 +30,22 @@ class SendMailTest extends \PHPUnit_Framework_TestCase {
$expect = [];
$this->assertEquals($expect, $result);
// Simple 'fixed position' DEPRECATED - not sure if it's ok that the array is not fillled up to the maximum.
// Simple 'fixed position' DEPRECATED - not sure if it's ok that the array is not filled up to the maximum.
// $result = $this->sendMail->parseStringToArray('john@doe.com|jane@miller.com|Latest|Dear John');
// $expect = ['john@doe.com', 'jane@miller.com', 'Latest', 'Dear John'];
// $this->assertEquals($expect, $result);
// Simple 'token based'
// Simple 'shorthand token based'
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John');
$expect = [SENDMAIL_TOKEN_RECEIVER => 'john@doe.com', SENDMAIL_TOKEN_SENDER => 'jane@miller.com',
SENDMAIL_TOKEN_SUBJECT => 'Latest', SENDMAIL_TOKEN_BODY => 'Dear John'];
$this->assertEquals($expect, $result);
// Simple 'speaking word based'
$result = $this->sendMail->parseStringToArray('to:john@doe.com|from:jane@miller.com|subject:Latest|body:Dear John');
$this->assertEquals($expect, $result);
// Simple 'speaking word / shorthand' mixed tokens
$result = $this->sendMail->parseStringToArray('to:john@doe.com|f:jane@miller.com|s:Latest|body:Dear John');
$this->assertEquals($expect, $result);
// All (but attachment) 'token based'
$result = $this->sendMail->parseStringToArray('t:john@doe.com|f:jane@miller.com|s:Latest|b:Dear John|r:reply@doe.com|A:on|g:123|x:234|c:july@doe.com,steve@doe.com|B:ceo@doe.com|h:Auto-Submit: fake|y:345|z:456|S:test.php');
......@@ -49,6 +55,9 @@ class SendMailTest extends \PHPUnit_Framework_TestCase {
SENDMAIL_TOKEN_RECEIVER_CC => 'july@doe.com,steve@doe.com', SENDMAIL_TOKEN_RECEIVER_BCC => 'ceo@doe.com',
SENDMAIL_TOKEN_HEADER => 'Auto-Submit: fake', SENDMAIL_TOKEN_X_ID2 => '345', SENDMAIL_TOKEN_X_ID3 => '456', SENDMAIL_TOKEN_SRC => 'test.php'];
$this->assertEquals($expect, $result);
// All (but attachment) 'speaking word based'
$result = $this->sendMail->parseStringToArray('to:john@doe.com|from:jane@miller.com|subject:Latest|body:Dear John|reply-to:reply@doe.com|autosubmit:on|grid:123|xid:234|cc:july@doe.com,steve@doe.com|bcc:ceo@doe.com|header:Auto-Submit: fake|xid2:345|xid3:456|source:test.php');
$this->assertEquals($expect, $result);
// Single attachment 'token based'
$attach = [['F:fileadmin/test1.pdf']];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment