Expertise developer

Laravel SMS Notification Channel for Morocco: Complete Guide

Learn how to integrate SMS notifications in Laravel 10/11 for Morocco with EnvoiSMS. Covers custom notification channels, queues, and +212 formatting.

Laravel SMS Notification Channel for Morocco: Complete Guide

1. Installation & Environment Configuration

Integrating SMS into Laravel applications is seamless. Install the EnvoiSMS package or create a custom notification driver. Add your credentials (ENVOISMS_API_KEY) in your .env and config/services.php files.

2. Creating a Custom SMS Notification Channel

Build a dedicated notification channel EnvoiSmsChannel with a send($notifiable, Notification $notification) method that extracts the recipient phone number and dispatches the HTTP request via Laravel's Http::withToken() facade.

3. Moroccan Mobile Phone Validation in FormRequests

Validate phone numbers strictly using regex rules in Laravel FormRequests: regex:/^(\+212|0)([67])[0-9]{8}$/. Convert matching numbers to E.164 format before persisting to the database.

4. Asynchronous Queue Processing with Horizon

Always dispatch notifications via queue workers (implements ShouldQueue). This guarantees instant response times for web requests while workers deliver SMS messages in the background with automatic retry handling.

5. Webhook Routes and DLR Ingestion in Laravel

Create a dedicated route /api/webhooks/envoisms protected by a signature verification middleware. Update message models asynchronously when carrier delivery receipts arrive.

💡 Why choose EnvoiSMS for your business?

⚡

Carrier Delivery

Local routes to IAM, Orange and Inwi, with automatic failover between routes and delivery status sent by webhook.

💰

Cost Optimization

WhatsApp Business API from 0.65 MAD per message with optimal ROI.

🛡️

Sovereign Data (CNDP)

Full compliance with Moroccan personal data protection regulations (CNDP).

Q.Which Laravel versions are supported?
Compatible with Laravel 9, 10, and 11+.
Q.How do I test notifications during local development?
Use the EnvoiSMS sandbox environment to simulate deliveries without sending real SMS.

Suggested Articles

Inbound Webhooks: Connect TikTok & Meta Lead Ads Directly to WhatsApp for Instant Conversion
developer

Inbound Webhooks: Connect TikTok & Meta Lead Ads Directly to WhatsApp for Instant Conversion

WhatsApp Flows: Native In-Chat Forms for COD Order Verification in Morocco
developer

WhatsApp Flows: Native In-Chat Forms for COD Order Verification in Morocco

Laravel SMS Morocco: Notification Channel and Tutorial
developer

Laravel SMS Morocco: Notification Channel and Tutorial