Laravel:如何正确地向注册控制器中具有不同url/的多个用户发送通知

Laravel:如何正确地向注册控制器中具有不同url/的多个用户发送通知,laravel,laravel-6,laravel-authorization,laravel-authentication,Laravel,Laravel 6,Laravel Authorization,Laravel Authentication,我正在尝试在使用默认身份验证laravel 6注册后向用户发送通知。我尝试使用通知facade,但它为所有电子邮件提供相同的URL。我试着使用->通知,但它给了我错误。顺便说一下,我正在使用smtp.office365.com 预期响应代码354,但得到代码“503”,消息为“503 5.5.1命令序列错误” 注册表控制器 protected $level; /** * Create a new notification instance. */ public function __con

我正在尝试在使用默认身份验证laravel 6注册后向用户发送通知。我尝试使用通知facade,但它为所有电子邮件提供相同的URL。我试着使用->通知,但它给了我错误。顺便说一下,我正在使用smtp.office365.com

预期响应代码354,但得到代码“503”,消息为“503 5.5.1命令序列错误”

注册表控制器

protected $level;

/**
 * Create a new notification instance.
 */
public function __construct($level)
{
    $this->level = $level;
}

/**
 * Get the notification's delivery channels.
 */
public function via($notifiable)
{
    return ['mail'];
}

/**
 * Get the mail representation of the notification.
 */
public function toMail($notifiable)
{
    return (new MailMessage)
        ->subject('Confirm User')
        ->greeting("Dear {$notifiable->name},")
        ->line('Please click the button below to confirm that the concerned user is your staff')
        ->action('Confirm User', url('/').$this->level)
        ->line('If you did not know the concerend staff, no further action is required.');
}

/**
 * Get the array representation of the notification.
 */
public function toArray($notifiable)
{
    return [
        //
    ];
}
$users=User::where('department\u id',$data['department'])
->其中(函数($query){
$query->where('manager\u level','sm1')
->orWhere(‘经理级’、‘sm2’)
->或where(‘部门级’、‘dh’);
})->get();
foreach(用户为$u){
$u->notify(新确认用户($u->department\u level='dh')?$u->department\u level:$u->manager\u level));
}
}
不确定用户

protected $level;

/**
 * Create a new notification instance.
 */
public function __construct($level)
{
    $this->level = $level;
}

/**
 * Get the notification's delivery channels.
 */
public function via($notifiable)
{
    return ['mail'];
}

/**
 * Get the mail representation of the notification.
 */
public function toMail($notifiable)
{
    return (new MailMessage)
        ->subject('Confirm User')
        ->greeting("Dear {$notifiable->name},")
        ->line('Please click the button below to confirm that the concerned user is your staff')
        ->action('Confirm User', url('/').$this->level)
        ->line('If you did not know the concerend staff, no further action is required.');
}

/**
 * Get the array representation of the notification.
 */
public function toArray($notifiable)
{
    return [
        //
    ];
}

要修复错误消息,请在配置文件中将
MAIL\u ENCRYPTION
的值更改为
tls
,并确保
MAIL\u FROM\u地址
正是您的Office 365电子邮件地址

请告诉我们有关
->部门
属性的更多信息。这个部门不可能是一样的吗?还是邮件中的
null

在您编写的代码中,
$u->deparment
没有
t
。因此,将其更改为:

u->notify(new ConfirmUser($u->department));

这最终可能会解决您的问题。

要修复错误消息,请将配置文件中的
MAIL\u ENCRYPTION
的值更改为
tls
,并确保
MAIL\u FROM\u地址正好是您的Office 365电子邮件地址

请告诉我们有关
->部门
属性的更多信息。这个部门不可能是一样的吗?还是邮件中的
null

在您编写的代码中,
$u->deparment
没有
t
。因此,将其更改为:

u->notify(new ConfirmUser($u->department));


这可能最终会解决您的问题。

试试
url(''.'/'.$This->department
@Vibha Chosla问题持续存在您到底在做什么?只是确认某人的电子邮件地址?您能告诉我们,您的循环中有多少
$users
?确保
$this->department
有一个值try
url(“”)。“/”。$this->department
@Vibha Chosla问题持续存在您实际在做什么?只是确认某人的电子邮件地址?您能告诉我们,您的循环中有多少
$users
?确保
$this->department
有一个值。邮件发件人地址与我的电子邮件地址相同,并且邮件加密设置为tls。邮件将发送给与注册用户具有相同部门的用户。邮件内容相同,但url(“/”)除外。我需要有一个不同的URL,因为我将为每个收件人设置不同的令牌。因此,请解释有关此部门属性的更多信息。如何存储它、数据库、控制器以及更多。没有足够的信息,因此有人现在可以知道问题出在哪里。它与通知外观无关。问题是您的部门属性始终具有相同的值。我检查了邮箱,发现邮箱中找不到默认的验证电子邮件地址。可能发生了什么?默认的验证电子邮件地址是什么意思?请发布您的电子邮件配置(密码除外)。在laravel中,我制作了php artisan make:auth,因此当我注册时,请验证注册后是否发送了电子邮件。当我检查邮箱时,使用通知::send($users,new ConfirmUser(…);,发送的邮件只有3封;。验证电子邮件未发送,错误错误错误命令序列作为响应给出。MAIL_FROM_地址与我的电子邮件地址相同,并且MAIL_加密设置为tls。邮件将发送给与注册用户具有相同部门的用户。邮件内容相同,但url(“/”)除外。我需要有一个不同的URL,因为我将为每个收件人设置不同的令牌。因此,请解释有关此部门属性的更多信息。如何存储它、数据库、控制器以及更多。没有足够的信息,因此有人现在可以知道问题出在哪里。它与通知外观无关。问题是您的部门属性始终具有相同的值。我检查了邮箱,发现邮箱中找不到默认的验证电子邮件地址。可能发生了什么?默认的验证电子邮件地址是什么意思?请发布您的电子邮件配置(密码除外)。在laravel中,我制作了php artisan make:auth,因此当我注册时,请验证注册后是否发送了电子邮件。当我检查邮箱时,使用通知::send($users,new ConfirmUser(…);,发送的邮件只有3封;。验证电子邮件未发送,错误错误命令序列作为响应给出。