44
55use Illuminate \Bus \Queueable ;
66use Illuminate \Mail \Mailable ;
7+ use Illuminate \Mail \Mailables \Content ;
8+ use Illuminate \Mail \Mailables \Envelope ;
79use Illuminate \Queue \SerializesModels ;
810
911class ExceptionOccurred extends Mailable
@@ -21,22 +23,43 @@ public function __construct($content)
2123 }
2224
2325 /**
24- * Build the message.
26+ * Get the message envelope .
2527 */
26- public function build (): Mailable
28+ public function envelope (): Envelope
2729 {
28- $ emailsTo = str_getcsv (config ('emailExceptionsTo ' , '' ));
29- $ ccEmails = str_getcsv (config ('emailExceptionCCto ' , '' ));
30- $ bccEmails = str_getcsv (config ('emailExceptionBCCto ' , '' ));
31- $ fromSender = config ('emailExceptionFrom ' , '' );
32- $ subject = config ('emailExceptionSubject ' , '' );
33-
34- return $ this ->from ($ fromSender )
35- ->to ($ emailsTo )
36- ->cc ($ ccEmails )
37- ->bcc ($ bccEmails )
38- ->subject ($ subject )
39- ->view (config ('emailExceptionView ' ))
40- ->with ('content ' , $ this ->content );
30+ $ emailsTo = config ('exceptions.emailExceptionsTo ' , false ) ?
31+ str_getcsv (config ('exceptions.emailExceptionsTo ' )) :
32+ null ;
33+ $ emailsCc = config ('exceptions.emailExceptionCCto ' , false ) ?
34+ str_getcsv (config ('exceptions.emailExceptionCCto ' )) :
35+ null ;
36+ $ emailsBcc = config ('exceptions.emailExceptionBCCto ' , false ) ?
37+ str_getcsv (config ('exceptions.emailExceptionBCCto ' )) :
38+ null ;
39+ $ fromSender = config ('exceptions.emailExceptionFrom ' );
40+ $ subject = config ('exceptions.emailExceptionSubject ' );
41+
42+ return new Envelope (
43+ from: $ fromSender ,
44+ to: $ emailsTo ,
45+ cc: $ emailsCc ,
46+ bcc: $ emailsBcc ,
47+ subject: $ subject
48+ );
49+ }
50+
51+ /**
52+ * Get the message content definition.
53+ */
54+ public function content (): Content
55+ {
56+ $ view = config ('exceptions.emailExceptionView ' );
57+
58+ return new Content (
59+ view: $ view ,
60+ with: [
61+ 'content ' => $ this ->content
62+ ]
63+ );
4164 }
4265}
0 commit comments