test transactional emails
This commit is contained in:
@@ -8,14 +8,12 @@ use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EmailChannel
|
||||
{
|
||||
/**
|
||||
* Send the given notification.
|
||||
*/
|
||||
public function send(SendsEmail $notifiable, Notification $notification): void
|
||||
{
|
||||
$this->bootConfigs($notifiable);
|
||||
|
||||
if ($notification instanceof \App\Notifications\TestNotification) {
|
||||
$bcc = $notifiable->routeNotificationForEmail('test_notification_recipients');
|
||||
$bcc = $notifiable->routeNotificationForEmail('smtp_test_recipients');
|
||||
if (count($bcc) === 0) {
|
||||
$bcc = $notifiable->routeNotificationForEmail();
|
||||
}
|
||||
@@ -29,10 +27,9 @@ class EmailChannel
|
||||
[],
|
||||
fn (Message $message) => $message
|
||||
->from(
|
||||
$notifiable->extra_attributes?->get('from_address'),
|
||||
$notifiable->extra_attributes?->get('from_name')
|
||||
$notifiable->extra_attributes?->get('smtp_from_address'),
|
||||
$notifiable->extra_attributes?->get('smtp_from_name')
|
||||
)
|
||||
->cc($bcc)
|
||||
->bcc($bcc)
|
||||
->subject($mailMessage->subject)
|
||||
->html((string)$mailMessage->render())
|
||||
|
||||
52
app/Notifications/TestTransactionEmail.php
Normal file
52
app/Notifications/TestTransactionEmail.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Notifications\Channels\EmailChannel;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TestTransactionEmail extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
$notifiable->extra_attributes?->get('smtp_host') && $channels[] = EmailChannel::class;
|
||||
return $channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$mail = new MailMessage();
|
||||
$mail->subject('Coolify Test Notification');
|
||||
$mail->view('emails.test-email');
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user