6
6
use Illuminate \Mail \Message ;
7
7
use Illuminate \Notifications \Notification ;
8
8
use Illuminate \Support \Facades \Mail ;
9
+ use Illuminate \Support \Str ;
9
10
10
11
class EmailChannel
11
12
{
12
13
public function send (SendsEmail $ notifiable , Notification $ notification ): void
13
14
{
14
15
$ this ->bootConfigs ($ notifiable );
15
- ray ($ notification );
16
16
$ recepients = $ notifiable ->getRecepients ($ notification );
17
17
18
18
if (count ($ recepients ) === 0 ) {
@@ -39,16 +39,21 @@ private function bootConfigs($notifiable): void
39
39
$ password = data_get ($ notifiable , 'smtp_password ' );
40
40
if ($ password ) $ password = decrypt ($ password );
41
41
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
+ }
53
58
}
54
59
}
0 commit comments