v0.1.10
This commit is contained in:
34
kernel/modules/notification/channels/EmailChannel.php
Normal file
34
kernel/modules/notification/channels/EmailChannel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\notification\channels;
|
||||
|
||||
use kernel\helpers\SMTP;
|
||||
use kernel\modules\notification\contracts\NotificationChannelInterface;
|
||||
use kernel\modules\notification\contracts\NotificationMessage;
|
||||
use kernel\modules\user\models\User;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
class EmailChannel implements NotificationChannelInterface
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send(NotificationMessage $notification, User $user): bool
|
||||
{
|
||||
$smtp = new SMTP();
|
||||
// Здесь можно использовать Laravel Mail
|
||||
// \Illuminate\Support\Facades\Mail::to($user->email)
|
||||
// ->send(new \App\Mail\NotificationMail(
|
||||
// $notification->getSubject(),
|
||||
// $notification->getMessage()
|
||||
// ));
|
||||
|
||||
return $smtp->send_html([
|
||||
'address' => $user->email,
|
||||
'subject' => $notification->getSubject(),
|
||||
'body' => $notification->getMessage(),
|
||||
'from_name' => $_ENV['MAIL_SMTP_USERNAME'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user