File tree Expand file tree Collapse file tree 3 files changed +48
-18
lines changed Expand file tree Collapse file tree 3 files changed +48
-18
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public function validator()
27
27
28
28
public function email ()
29
29
{
30
- return InboundEmail::fromMessage ($ this ->get ('body-mime ' ));
30
+ return InboundEmail::fromMessage ($ this ->get ('body-mime ' ));
31
31
}
32
32
33
33
protected function verifySignature ()
Original file line number Diff line number Diff line change @@ -75,32 +75,22 @@ public function callMailboxes(InboundEmail $email)
75
75
$ route ->run ($ email );
76
76
});
77
77
78
- if ($ matchedRoutes ->isEmpty ()) {
79
- $ this ->callFallback ($ email );
78
+ if ($ matchedRoutes ->isEmpty () && $ this ->fallbackRoute ) {
79
+ $ matchedRoutes [] = $ this ->fallbackRoute ;
80
+ $ this ->fallbackRoute ->run ($ email );
80
81
}
81
82
82
- $ this ->callCatchAll ($ email );
83
+ if ($ this ->catchAllRoute ) {
84
+ $ matchedRoutes [] = $ this ->catchAllRoute ;
85
+ $ this ->catchAllRoute ->run ($ email );
86
+ }
83
87
84
88
if ($ this ->shouldStoreInboundEmails () && $ this ->shouldStoreAllInboundEmails ($ matchedRoutes )) {
85
89
$ this ->storeEmail ($ email );
86
90
}
87
91
}
88
92
}
89
93
90
- protected function callFallback (InboundEmail $ email )
91
- {
92
- if ($ this ->fallbackRoute ) {
93
- $ this ->fallbackRoute ->run ($ email );
94
- }
95
- }
96
-
97
- protected function callCatchAll (InboundEmail $ email )
98
- {
99
- if ($ this ->catchAllRoute ) {
100
- $ this ->catchAllRoute ->run ($ email );
101
- }
102
- }
103
-
104
94
protected function shouldStoreInboundEmails (): bool
105
95
{
106
96
return config ('mailbox.store_incoming_emails_for_days ' ) > 0 ;
Original file line number Diff line number Diff line change @@ -74,6 +74,46 @@ public function it_can_use_catchall()
74
74
Mail::assertSent (ReplyMail::class);
75
75
}
76
76
77
+ /** @test */
78
+ public function it_stores_inbound_emails_with_catchall ()
79
+ {
80
+ Mailbox::catchAll (function ($ email ) {
81
+ });
82
+
83
+ Mail::to ('someone@beyondco.de ' )->send (new TestMail );
84
+ Mail::to ('someone-else@beyondco.de ' )->send (new TestMail );
85
+
86
+ $ this ->assertSame (2 , InboundEmail::query ()->count ());
87
+ }
88
+
89
+ /** @test */
90
+ public function it_stores_inbound_emails_with_fallback ()
91
+ {
92
+ Mailbox::fallback (function ($ email ) {
93
+ });
94
+
95
+ Mail::to ('someone@beyondco.de ' )->send (new TestMail );
96
+ Mail::to ('someone-else@beyondco.de ' )->send (new TestMail );
97
+
98
+ $ this ->assertSame (2 , InboundEmail::query ()->count ());
99
+ }
100
+
101
+ /** @test */
102
+ public function it_stores_inbound_emails_with_fallback_and_catchall_only_once ()
103
+ {
104
+ Mailbox::fallback (function ($ email ) {
105
+ });
106
+
107
+ Mailbox::catchAll (function ($ email ) {
108
+ });
109
+
110
+ Mail::to ('someone@beyondco.de ' )->send (new TestMail );
111
+ Mail::to ('someone-else@beyondco.de ' )->send (new TestMail );
112
+
113
+ $ this ->assertSame (2 , InboundEmail::query ()->count ());
114
+ }
115
+
116
+
77
117
/** @test */
78
118
public function it_does_not_store_inbound_emails_if_configured ()
79
119
{
You can’t perform that action at this time.
0 commit comments