

Public function routeNotificationForVonage($notification) Use Illuminate\Foundation\Auth\User as Authenticatable
#Free sms sender api update#
For example, we could update our model to look like so: namespace App\Models

So, we create a new routeNotificationForVonage method on our User model that returns the phone_number field. At the moment, it has no idea which phone number to use. Whenever we send an SMS notification in Laravel, we need to let Laravel know where to grab the recipient's phone number from. In this example, we're going to imagine that we want to send the SMS to our User models and that they have their phone number stored in a phone_number field. Now that we have the notification channel set up, we need to configure our model. Further down, we'll discuss how you can override this value on a notification-by-notification basis when sending the SMS messages. If you've bought a phone number from Vonage, you may want to put that number here or you might want to use your brand/company name here instead. This will be the number (or name) that the message will appear as being sent by. env file and add our API keys that we got after creating our Vonage account: VONAGE_KEY=your-vonage-key-hereĪs you can see, we've also added a VONAGE_SMS_FROM field too.
#Free sms sender api install#
Now that we've created our Vonage account and got our API keys, we can install Laravel's first-party notification channel for Vonage ( laravel/vonage-notification-channel) using the following command: composer require laravel/vonage-notification-channel Once you're ready to use Vonage and lift the restrictions, you can upgrade to a paid account.


Sending SMS Using Vonage Create a Vonage Accountīefore we touch any code in our projects, you'll first need to create a Vonage account. In this particular guide, we'll be using the SMS API. Verify API - for adding 2FA functionality and verifying a user's phone number or identity.SMS API - for sending and receiving SMS.Vonage offers several different APIs that you can use, including:
#Free sms sender api how to#
In this guide, we're going to take a look at how to use Vonage (who were previously named Nexmo) to send an SMS message to your users from your Laravel app. To send the messages, you'll typically need to interact with a third-party service's API (such as Vonage or Twilio) that can handle the sending (and sometimes receiving) of your messages. You might want to do this to send notifications to your users, or maybe as a form of 2FA (two factor authentication). In your Laravel applications, there may be times that you want to send SMS messages to your users.
