D
D
Dmitry Kuznetsov2015-11-22 23:09:09
PHP
Dmitry Kuznetsov, 2015-11-22 23:09:09

Error sending E-Mail in Laravel, what should I do?

There is a model that sends an E-Mail message.

class MailSend extends Eloquent{
  /**
   * Отправка сообщения на E-Mail об
   * успешной регистрации
   * @param  [array]  $data [Данные]
   * @param  [string] $key  [Ключ активации]
   * @return [type]         [description]
   */
  public static function sendActivationsUsers($data, $key){
    $login = $data['login_users'];
    $mail = $data['mail_users'];

    Mail::send('emails.auth.register', ['login' => $login, 'mail' => $mail, 'key' => $key], function($msg){
      $msg->to($mail)->subject("С успешной регистрацией!");	// Кому
    });
  }
}

But it says that $mail does not exist. What to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-11-22
@dima9595

Because it needs to be like this:

Mail::send('emails.auth.register', ['login' => $login, 'mail' => $mail, 'key' => $key], function($msg) use ($mail) {
      $msg->to($mail)->subject("С успешной регистрацией!");	// Кому
    });

This is not Laravel's fault, it's your ignorance of PHP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question