0

I try to make, send SMS using simple-sms Laravel package. Then user activated he get sms message with text: Activated!, but i dont getting sms by tag $phone, if i use phone like that: "+4425652125", everything works fine. My code looks like that:

public function activate($token, User $user)
{
    $user = User::whereActivationToken($token)->firstOrFail();
    $user->confirmEmail();
    $phone = $user->phone;

    flash()->success(trans('frontend.account.activated'));

    SMS::send('Your SMS Message', null, function($sms) use ($phone) {
        $sms->to($phone);
    });
}

Any ideas?

  • 2
    Look at `'$phone'`. That's a literal string, not a variable. Don't quote variables, unless needed. – chris85 Mar 03 '17 at 13:21
  • Possible duplicate of [What is the difference between single-quoted and double-quoted strings in PHP?](http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – chris85 Mar 03 '17 at 13:23
  • Changed to: ` $sms->to($phone);` and now getting erro: Undefined variable: phone – ром Макаров Mar 03 '17 at 13:23
  • 2
    You need to pass it in to the function. Maybe `function($sms) use ($phone)` – chris85 Mar 03 '17 at 13:24
  • @chris85 no erros, but still dont getting messages. Still getting $phone instead of +445455125 – ром Макаров Mar 03 '17 at 13:35
  • @ромМакаров What do you mean `still dont getting messages` and `getting $phone`? Are you not getting the message, the contents of the message are wrong, or something else? – chris85 Mar 03 '17 at 13:37
  • My message trying to send to number $phone but not +445455125. $phone does not working in: $sms->to($phone); really really weird – ром Макаров Mar 03 '17 at 13:38
  • @chris85 it's native by: [link](https://www.simplesoftware.io/docs/simple-sms#docs-usage) – ром Макаров Mar 03 '17 at 13:43
  • Strange, while outside my area, PHP all looks right to me. You've checked server code and made sure the `$phone` is literal and not quoted still, that's my last guess. – chris85 Mar 03 '17 at 13:50

0 Answers0