66use Illuminate \Mail \Message ;
77use Illuminate \Notifications \Notification ;
88use Illuminate \Support \Facades \Mail ;
9+ use Illuminate \Support \Str ;
910
1011class EmailChannel
1112{
1213 public function send (SendsEmail $ notifiable , Notification $ notification ): void
1314 {
1415 $ this ->bootConfigs ($ notifiable );
15- ray ($ notification );
1616 $ recepients = $ notifiable ->getRecepients ($ notification );
1717
1818 if (count ($ recepients ) === 0 ) {
@@ -39,16 +39,21 @@ private function bootConfigs($notifiable): void
3939 $ password = data_get ($ notifiable , 'smtp_password ' );
4040 if ($ password ) $ password = decrypt ($ password );
4141
42- config ()->set ('mail.default ' , 'smtp ' );
43- config ()->set ('mail.mailers.smtp ' , [
44- "transport " => "smtp " ,
45- "host " => data_get ($ notifiable , 'smtp_host ' ),
46- "port " => data_get ($ notifiable , 'smtp_port ' ),
47- "encryption " => data_get ($ notifiable , 'smtp_encryption ' ),
48- "username " => data_get ($ notifiable , 'smtp_username ' ),
49- "password " => $ password ,
50- "timeout " => data_get ($ notifiable , 'smtp_timeout ' ),
51- "local_domain " => null ,
52- ]);
42+ if (Str::contains (data_get ($ notifiable , 'smtp_host ' ),'resend.com ' )) {
43+ config ()->set ('mail.default ' , 'resend ' );
44+ config ()->set ('resend.api_key ' , $ password );
45+ } else {
46+ config ()->set ('mail.default ' , 'smtp ' );
47+ config ()->set ('mail.mailers.smtp ' , [
48+ "transport " => "smtp " ,
49+ "host " => data_get ($ notifiable , 'smtp_host ' ),
50+ "port " => data_get ($ notifiable , 'smtp_port ' ),
51+ "encryption " => data_get ($ notifiable , 'smtp_encryption ' ),
52+ "username " => data_get ($ notifiable , 'smtp_username ' ),
53+ "password " => $ password ,
54+ "timeout " => data_get ($ notifiable , 'smtp_timeout ' ),
55+ "local_domain " => null ,
56+ ]);
57+ }
5358 }
5459}
0 commit comments