4
4
5
5
use Illuminate \Bus \Queueable ;
6
6
use Illuminate \Mail \Mailable ;
7
+ use Illuminate \Mail \Mailables \Content ;
8
+ use Illuminate \Mail \Mailables \Envelope ;
7
9
use Illuminate \Queue \SerializesModels ;
8
10
9
11
class ExceptionOccurred extends Mailable
@@ -21,22 +23,43 @@ public function __construct($content)
21
23
}
22
24
23
25
/**
24
- * Build the message.
26
+ * Get the message envelope .
25
27
*/
26
- public function build (): Mailable
28
+ public function envelope (): Envelope
27
29
{
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
+ );
41
64
}
42
65
}
0 commit comments