I'm working on a laravel backpack project. I have created an Event CRUD and each event has its own admin and SMTP details. Admin can sent invites to users for that event. I have already set sendgrid SMTP in my '.env' file and created a notification to send invites. Its working fine and sends invites notification to the users for that particular event through sendgrid SMTP. But I want notification to be sent out with that particualr event's SMTP.
I have searched a lot but couldn't find a feasible solution for that. Would really appreciate if anyone can point me into right direction.
Below is my Invites Notification class code:
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class EventUserInvitation extends Notification
{
// use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($event_user)
{
$this->event_user = $event_user;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject('You are invited to ' .$this->event_user->get_event->name. ' at SpaceTo app')
->line('You have received this email to join the meeting created by ' . (($this->event_user->get_event->user) ? $this->event_user->get_event->user->name : $this->event_user->get_event->event_admin[0]->name) . '. Please click on the link below to proceed. ')
->line('If your browser doesn’t support automatic redirection please copy and paste the link to your browser address field.')
->action('Open SpaceTo App', url('/') . '/app')
->line('This email is an automated email please do not reply. ')
->line('In case if you have any questions please contact our support team support@spaceto.com')
->line('Have a great day.')
->line('Spaceto team. ');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}