File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,17 @@ public function getMailboxByEmail($email)
167167
168168 throw new \Exception ("No mailbox found for email ' $ email' " );
169169 }
170+
171+ public function getMailboxByToEmail ($ email )
172+ {
173+ foreach ($ this ->getRegisteredMailboxes () as $ registeredMailbox ) {
174+ if ($ email === $ registeredMailbox ['imap_server ' ]['username ' ]) {
175+ return true ;
176+ }
177+ }
178+
179+ return false ;
180+ }
170181
171182 private function searchticketSubjectRefrence ($ senderEmail , $ messageSubject ) {
172183
@@ -302,9 +313,15 @@ public function processMail($rawEmail)
302313 // An exception being thrown means no mailboxes were found from the recipient's address. Continue processing.
303314 }
304315 }
316+
317+ foreach ($ addresses ['to ' ] as $ mailboxEmail ){
318+ if ($ this ->getMailboxByToEmail (strtolower ($ mailboxEmail ))){
319+ $ mailData ['replyTo ' ] = $ mailboxEmail ;
320+ }
321+ }
305322
306323 // Process Mail - References
307- $ addresses ['to ' ][0 ] = strtolower ($ addresses ['to ' ][0 ]);
324+ $ addresses ['to ' ][0 ] = strtolower ($ mailData [ ' replyTo ' ]) ?? strtolower ( $ addresses ['to ' ][0 ]);
308325 $ mailData ['replyTo ' ] = $ addresses ['to ' ];
309326 $ mailData ['messageId ' ] = $ parser ->getHeader ('message-id ' ) ?: null ;
310327 $ mailData ['inReplyTo ' ] = htmlspecialchars_decode ($ parser ->getHeader ('in-reply-to ' ));
@@ -439,4 +456,4 @@ public function processMail($rawEmail)
439456
440457 return ;
441458 }
442- }
459+ }
You can’t perform that action at this time.
0 commit comments