samedi 25 février 2017

Mail::send laravel - How to access $message->to($variable);

I'm using the function below to send Email:

public static function send_welcome_mail($user,$code)
{
    Mail::send('auth.email.welcome',['user'=>$user,'code'=>$code], function ($message)
    {
        $message->subject('Welcome');
        $message->from('info@example.com', 'Example');
        $message->to('info@exampleReceiver.com');
    });
}

Sending Email works fine , but when i change to this (add receiver):

public static function send_welcome_mail($user,$code,$receiver)
{
    Mail::send('auth.email.welcome',['user'=>$user,'code'=>$code], function ($message)
    {
        $message->subject('Welcome');
        $message->from('info@example.com', 'Example');
        $message->to($receiver);
    });
}

I got error:

Undefined variable: receiverEmail



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire