File tree 11 files changed +60
-18
lines changed
tests/Messaging/Adapter/Email
11 files changed +60
-18
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ MSG_91_TO=
20
20
MSG_91_FROM =
21
21
TEST_EMAIL =
22
22
TEST_FROM_EMAIL =
23
+ TEST_CC_EMAIL =
24
+ TEST_BCC_EMAIL =
25
+ TEST_BCC_NAME =
23
26
VONAGE_API_KEY =
24
27
VONAGE_API_SECRET =
25
28
VONAGE_TO =
Original file line number Diff line number Diff line change 36
36
MSG_91_FROM : ${{ secrets.MSG_91_FROM }}
37
37
TEST_EMAIL : ${{ secrets.TEST_EMAIL }}
38
38
TEST_FROM_EMAIL : ${{ secrets.TEST_FROM_EMAIL }}
39
+ TEST_CC_EMAIL : ${{ secrets.TEST_CC_EMAIL }}
40
+ TEST_BCC_EMAIL : ${{ secrets.TEST_BCC_EMAIL }}
41
+ TEST_BCC_NAME : ${{ secrets.TEST_BCC_NAME }}
39
42
VONAGE_API_KEY : ${{ secrets.VONAGE_API_KEY }}
40
43
VONAGE_API_SECRET : ${{ secrets.VONAGE_API_SECRET }}
41
44
VONAGE_TO : ${{ secrets.VONAGE_TO }}
Original file line number Diff line number Diff line change 1
- FROM composer:2.0 as composer
1
+ FROM composer:2.0 AS composer
2
2
3
3
ARG TESTING=false
4
4
ENV TESTING=$TESTING
@@ -15,7 +15,7 @@ RUN composer install \
15
15
--no-scripts \
16
16
--prefer-dist
17
17
18
- FROM php:8.2.14 -cli-alpine3.19
18
+ FROM php:8.3.11 -cli-alpine3.20
19
19
20
20
WORKDIR /usr/local/src/
21
21
Original file line number Diff line number Diff line change 1
- version : ' 3.9'
2
-
3
1
services :
4
2
tests :
5
3
build :
@@ -31,6 +29,9 @@ services:
31
29
- MSG_91_FROM
32
30
- TEST_EMAIL
33
31
- TEST_FROM_EMAIL
32
+ - TEST_CC_EMAIL
33
+ - TEST_BCC_EMAIL
34
+ - TEST_BCC_NAME
34
35
- VONAGE_API_KEY
35
36
- VONAGE_API_SECRET
36
37
- VONAGE_TO
Original file line number Diff line number Diff line change @@ -58,20 +58,28 @@ protected function process(EmailMessage $message): array
58
58
59
59
if (!\is_null ($ message ->getCC ())) {
60
60
foreach ($ message ->getCC () as $ cc ) {
61
- if (!empty ($ cc ['name ' ])) {
62
- $ body ['cc ' ] = "{$ body ['cc ' ]}, {$ cc ['name ' ]}< {$ cc ['email ' ]}> " ;
63
- } else {
64
- $ body ['cc ' ] = "{$ body ['cc ' ]}, < {$ cc ['email ' ]}> " ;
61
+ if (!empty ($ cc ['email ' ])) {
62
+ $ ccString = !empty ($ cc ['name ' ])
63
+ ? "{$ cc ['name ' ]}< {$ cc ['email ' ]}> "
64
+ : $ cc ['email ' ];
65
+
66
+ $ body ['cc ' ] = !empty ($ body ['cc ' ])
67
+ ? "{$ body ['cc ' ]}, {$ ccString }"
68
+ : $ ccString ;
65
69
}
66
70
}
67
71
}
68
72
69
73
if (!\is_null ($ message ->getBCC ())) {
70
74
foreach ($ message ->getBCC () as $ bcc ) {
71
- if (!empty ($ bcc ['name ' ])) {
72
- $ body ['bcc ' ] = "{$ body ['bcc ' ]}, {$ bcc ['name ' ]}< {$ bcc ['email ' ]}> " ;
73
- } else {
74
- $ body ['bcc ' ] = "{$ body ['bcc ' ]}, < {$ bcc ['email ' ]}> " ;
75
+ if (!empty ($ bcc ['email ' ])) {
76
+ $ bccString = !empty ($ bcc ['name ' ])
77
+ ? "{$ bcc ['name ' ]}< {$ bcc ['email ' ]}> "
78
+ : $ bcc ['email ' ];
79
+
80
+ $ body ['bcc ' ] = !empty ($ body ['bcc ' ])
81
+ ? "{$ body ['bcc ' ]}, {$ bccString }"
82
+ : $ bccString ;
75
83
}
76
84
}
77
85
}
Original file line number Diff line number Diff line change @@ -50,6 +50,18 @@ protected function process(EmailMessage $message): array
50
50
$ mail ->addAddress ($ to );
51
51
}
52
52
53
+ if (!empty ($ message ->getCC ())) {
54
+ foreach ($ message ->getCC () as $ cc ) {
55
+ $ mail ->addCC ($ cc ['email ' ], $ cc ['name ' ] ?? '' );
56
+ }
57
+ }
58
+
59
+ if (!empty ($ message ->getBCC ())) {
60
+ foreach ($ message ->getBCC () as $ bcc ) {
61
+ $ mail ->addBCC ($ bcc ['email ' ], $ bcc ['name ' ] ?? '' );
62
+ }
63
+ }
64
+
53
65
if (!$ mail ->send ()) {
54
66
foreach ($ message ->getTo () as $ to ) {
55
67
$ response ->addResult ($ to , $ mail ->ErrorInfo );
Original file line number Diff line number Diff line change @@ -78,13 +78,13 @@ protected function process(EmailMessage $message): array
78
78
79
79
if (!empty ($ message ->getCC ())) {
80
80
foreach ($ message ->getCC () as $ cc ) {
81
- $ mail ->addCC ($ cc ['email ' ], $ cc ['name ' ]);
81
+ $ mail ->addCC ($ cc ['email ' ], $ cc ['name ' ] ?? '' );
82
82
}
83
83
}
84
84
85
85
if (!empty ($ message ->getBCC ())) {
86
86
foreach ($ message ->getBCC () as $ bcc ) {
87
- $ mail ->addBCC ($ bcc ['email ' ], $ bcc ['name ' ]);
87
+ $ mail ->addBCC ($ bcc ['email ' ], $ bcc ['name ' ] ?? '' );
88
88
}
89
89
}
90
90
Original file line number Diff line number Diff line change @@ -45,16 +45,16 @@ public function __construct(
45
45
46
46
if (!\is_null ($ this ->cc )) {
47
47
foreach ($ this ->cc as $ recipient ) {
48
- if (!isset ($ recipient ['name ' ]) || ! isset ( $ recipient [ ' email ' ])) {
49
- throw new \InvalidArgumentException ('Each recipient in cc must have a name and email ' );
48
+ if (!isset ($ recipient ['email ' ])) {
49
+ throw new \InvalidArgumentException ('Each CC recipient must have at least an email ' );
50
50
}
51
51
}
52
52
}
53
53
54
54
if (!\is_null ($ this ->bcc )) {
55
55
foreach ($ this ->bcc as $ recipient ) {
56
- if (!isset ($ recipient ['name ' ]) || ! isset ( $ recipient [ ' email ' ])) {
57
- throw new \InvalidArgumentException ('Each recipient in bcc must have a name and email ' );
56
+ if (!isset ($ recipient ['email ' ])) {
57
+ throw new \InvalidArgumentException ('Each BCC recipient must have at least an email ' );
58
58
}
59
59
}
60
60
}
Original file line number Diff line number Diff line change @@ -17,13 +17,17 @@ public function testSendEmail(): void
17
17
$ content = 'Test Content ' ;
18
18
$ fromName = 'Test Sender ' ;
19
19
20
+ $ cc = [[
'email ' =>
'[email protected] ' ]];
21
+ $ bcc = [[
'name ' =>
'Tester3 ' ,
'email ' =>
'[email protected] ' ]];
20
22
21
23
$ message = new Email (
22
24
to: [$ to ],
23
25
subject: $ subject ,
24
26
content: $ content ,
25
27
fromName: $ fromName ,
26
28
fromEmail: $ fromEmail ,
29
+ cc: $ cc ,
30
+ bcc: $ bcc ,
27
31
);
28
32
29
33
$ response = $ sender ->send ($ message );
@@ -33,7 +37,10 @@ public function testSendEmail(): void
33
37
$ this ->assertResponse ($ response );
34
38
$ this ->assertEquals ($ to , $ lastEmail ['to ' ][0 ]['address ' ]);
35
39
$ this ->assertEquals ($ fromEmail , $ lastEmail ['from ' ][0 ]['address ' ]);
40
+ $ this ->assertEquals ($ fromName , $ lastEmail ['from ' ][0 ]['name ' ]);
36
41
$ this ->assertEquals ($ subject , $ lastEmail ['subject ' ]);
37
42
$ this ->assertEquals ($ content , \trim ($ lastEmail ['text ' ]));
43
+ $ this ->assertEquals ($ cc [0 ]['email ' ], $ lastEmail ['cc ' ][0 ]['address ' ]);
44
+ $ this ->assertEquals ($ bcc [0 ]['email ' ], $ lastEmail ['envelope ' ]['to ' ][2 ]['address ' ]);
38
45
}
39
46
}
Original file line number Diff line number Diff line change @@ -24,13 +24,17 @@ public function testSendEmail(): void
24
24
$ subject = 'Test Subject ' ;
25
25
$ content = 'Test Content ' ;
26
26
$ fromEmail = 'sender@ ' .$ domain ;
27
+ $ cc = [['email ' => \getenv ('TEST_CC_EMAIL ' )]];
28
+ $ bcc = [['name ' => \getenv ('TEST_BCC_NAME ' ), 'email ' => \getenv ('TEST_BCC_EMAIL ' )]];
27
29
28
30
$ message = new Email (
29
31
to: [$ to ],
30
32
subject: $ subject ,
31
33
content: $ content ,
32
34
fromName: 'Test Sender ' ,
33
35
fromEmail: $ fromEmail ,
36
+ cc: $ cc ,
37
+ bcc: $ bcc ,
34
38
);
35
39
36
40
$ response = $ sender ->send ($ message );
Original file line number Diff line number Diff line change @@ -18,13 +18,17 @@ public function testSendEmail(): void
18
18
$ subject = 'Test Subject ' ;
19
19
$ content = 'Test Content ' ;
20
20
$ fromEmail = \getenv ('TEST_FROM_EMAIL ' );
21
+ $ cc = [['email ' => \getenv ('TEST_CC_EMAIL ' )]];
22
+ $ bcc = [['name ' => \getenv ('TEST_BCC_NAME ' ), 'email ' => \getenv ('TEST_BCC_EMAIL ' )]];
21
23
22
24
$ message = new Email (
23
25
to: [$ to ],
24
26
subject: $ subject ,
25
27
content: $ content ,
26
28
fromName: 'Tester ' ,
27
29
fromEmail: $ fromEmail ,
30
+ cc: $ cc ,
31
+ bcc: $ bcc ,
28
32
);
29
33
30
34
$ response = $ sender ->send ($ message );
You can’t perform that action at this time.
0 commit comments