Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
66618315
Commit
66618315
authored
Feb 09, 2018
by
Elias Villiger
Committed by
bbaer
Mar 01, 2018
Browse files
Feature #5318 - Allow sendmail speaking word tokens
parent
761efbb7
Changes
4
Hide whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
66618315
...
...
@@ -5506,7 +5506,7 @@ 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
>]
...
...
@@ -5516,7 +5516,7 @@ 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
>]
[|
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
.
...
...
@@ -5554,6 +5554,7 @@ Send emails. Every mail will be logged in the table `mailLog`. Attachments are s
| 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. | |
+------------+----------------------------------------+--------------------------------------------------------------------------------------------------+------------+
...
...
extension/qfq/qfq/Constants.php
View file @
66618315
...
...
@@ -1128,6 +1128,10 @@ 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'
;
...
...
@@ -1135,10 +1139,8 @@ 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_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'
;
...
...
extension/qfq/qfq/report/SendMail.php
View file @
66618315
...
...
@@ -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
...
...
@@ -365,12 +382,20 @@ class SendMail {
}
$tokenAndValue
=
explode
(
PARAM_TOKEN_DELIMITER
,
$line
,
2
);
if
(
count
(
$tokenAndValue
)
<
2
)
{
if
(
count
(
$tokenAndValue
)
<
2
&&
$tokenAndValue
[
0
]
!==
SENDMAIL_TOKEN_CONCAT
)
{
throw
new
UserFormException
(
'Missing token delimiter "'
.
PARAM_TOKEN_DELIMITER
.
'" in: '
.
$line
,
ERROR_UNKNOWN_TOKEN
);
}
// speaking word tokens are all lowercase
$token
=
strlen
(
$tokenAndValue
[
0
])
>
1
?
strtolower
(
$tokenAndValue
[
0
])
:
$tokenAndValue
[
0
];
$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
)
{
...
...
@@ -410,7 +435,7 @@ class SendMail {
break
;
default
:
$args
[
$token
]
=
substr
(
$line
,
2
)
;
$args
[
$token
]
=
$tokenAndValue
[
1
]
;
break
;
}
}
...
...
extension/qfq/tests/phpunit/SendMailTest.php
View file @
66618315
...
...
@@ -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 fill
l
ed 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'
]];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment