Skip to content

Commit 4339dba

Browse files
committed
split multiple sender_cc addrs on comma
1 parent 3e5ff9a commit 4339dba

File tree

1 file changed

+112
-6
lines changed

1 file changed

+112
-6
lines changed

install/tpl/mysql-virtual_outgoing_bcc.cf.master

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,116 @@ user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
44
hosts = {mysql_server_ip}
5-
query = SELECT sender_cc FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
5+
query = SELECT sender_cc FROM (
6+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
7+
SUBSTRING_INDEX(sender_cc, ',', 1) AS sender_cc
8+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
9+
UNION
10+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
11+
IF(@num_sender_cc > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 2), ',', -1), '') AS sender_cc
12+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
13+
UNION
14+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
15+
IF(@num_sender_cc > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 3), ',', -1), '') AS sender_cc
16+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
17+
UNION
18+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
19+
IF(@num_sender_cc > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 4), ',', -1), '') AS sender_cc
20+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
21+
UNION
22+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
23+
IF(@num_sender_cc > 4, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 5), ',', -1), '') AS sender_cc
24+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
25+
UNION
26+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
27+
IF(@num_sender_cc > 5, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 6), ',', -1), '') AS sender_cc
28+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
29+
UNION
30+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
31+
IF(@num_sender_cc > 6, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 7), ',', -1), '') AS sender_cc
32+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
33+
UNION
34+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
35+
IF(@num_sender_cc > 7, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 8), ',', -1), '') AS sender_cc
36+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
37+
UNION
38+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
39+
IF(@num_sender_cc > 8, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 9), ',', -1), '') AS sender_cc
40+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
41+
UNION
42+
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
43+
IF(@num_sender_cc > 9, SUBSTRING_INDEX(SUBSTRING_INDEX(sender_cc, ',', 10), ',', -1), '') AS sender_cc
44+
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
45+
) table1 WHERE sender_cc != ''
646
UNION
7-
SELECT u.sender_cc
8-
FROM mail_user u, mail_forwarding f
9-
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
10-
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
11-
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
47+
SELECT sender_cc FROM (
48+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
49+
SUBSTRING_INDEX(u.sender_cc, ',', 1) AS sender_cc
50+
FROM mail_user u, mail_forwarding f
51+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
52+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
53+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
54+
UNION
55+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
56+
IF(@num_sender_cc > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 2), ',', -1), '') AS sender_cc
57+
FROM mail_user u, mail_forwarding f
58+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
59+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
60+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
61+
UNION
62+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
63+
IF(@num_sender_cc > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 3), ',', -1), '') AS sender_cc
64+
FROM mail_user u, mail_forwarding f
65+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
66+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
67+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
68+
UNION
69+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
70+
IF(@num_sender_cc > 3, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 4), ',', -1), '') AS sender_cc
71+
FROM mail_user u, mail_forwarding f
72+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
73+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
74+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
75+
UNION
76+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
77+
IF(@num_sender_cc > 4, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 5), ',', -1), '') AS sender_cc
78+
FROM mail_user u, mail_forwarding f
79+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
80+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
81+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
82+
UNION
83+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
84+
IF(@num_sender_cc > 5, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 6), ',', -1), '') AS sender_cc
85+
FROM mail_user u, mail_forwarding f
86+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
87+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
88+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
89+
UNION
90+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
91+
IF(@num_sender_cc > 6, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 7), ',', -1), '') AS sender_cc
92+
FROM mail_user u, mail_forwarding f
93+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
94+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
95+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
96+
UNION
97+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
98+
IF(@num_sender_cc > 7, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 8), ',', -1), '') AS sender_cc
99+
FROM mail_user u, mail_forwarding f
100+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
101+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
102+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
103+
UNION
104+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
105+
IF(@num_sender_cc > 8, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 9), ',', -1), '') AS sender_cc
106+
FROM mail_user u, mail_forwarding f
107+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
108+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
109+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
110+
UNION
111+
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
112+
IF(@num_sender_cc > 9, SUBSTRING_INDEX(SUBSTRING_INDEX(u.sender_cc, ',', 10), ',', -1), '') AS sender_cc
113+
FROM mail_user u, mail_forwarding f
114+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
115+
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
116+
AND f.source = '%s' AND f.active = 'y' AND f.allow_send_as = 'y' AND f.server_id = {server_id}
117+
) table2 WHERE sender_cc != ''

0 commit comments

Comments
 (0)