Overview
Ecom supports SMS messaging and OTP (One-Time Password) verification through multiple SMS gateway providers. This enables:- Phone number verification during registration
- Password reset via SMS
- Order notifications
- Two-factor authentication
- Marketing messages
Supported SMS Gateways
- Twilio (Global)
- Nexmo/Vonage (Global)
- Fast2SMS (India)
- Mimo (Various)
- Mimsms (Various)
- Msegat (Middle East)
- Sparrow (Nepal)
Configuration
SMS Service Classes
Located in:OTP Configuration Model
SMS Contract Interface
app/Contracts/SendSms.php
Twilio Configuration
Step 1: Get Twilio Credentials
Create Twilio Account
Sign up at Twilio
Step 2: Configure Environment
.env
Step 3: Install Twilio SDK
Twilio SDK is already included:composer.json
Nexmo/Vonage Configuration
Implementation
app/Services/OTP/Nexmo.php
Environment Configuration
.env
Nexmo Config File
config/nexmo.php
Fast2SMS (India)
Configuration
.env
Features
- India-specific SMS gateway
- DND support
- Transactional and promotional SMS
- Template-based messaging
- Unicode support
OTP Verification Flow
Sending OTP
Verifying OTP
SMS Templates
Configure message templates in database:Template Variables
{customer_name}- Customer name{order_code}- Order code{otp_code}- OTP code{amount}- Order amount{delivery_status}- Delivery status
Example Templates
OTP Verification:Password Reset via SMS
Implementation
app/Http/Controllers/Auth/ForgotPasswordController.php
Regional SMS Gateways
Msegat (Middle East)
Popular in Saudi Arabia, UAE, Kuwait:.env
Sparrow (Nepal)
Nepal’s leading SMS gateway:.env
Mimo / Mimsms
Various regional coverage:.env
Admin Panel Configuration
Enable SMS Gateway
Testing SMS Integration
Development Testing
Test Mode Configuration
.env
Rate Limiting
Implement rate limiting for SMS:Cost Management
Phone Number Validation
Validate phone numbers before sending SMS:Multi-Language SMS
Support multiple languages in SMS:Delivery Reports
Track SMS delivery status:Troubleshooting
SMS Not Received
SMS Not Received
Check:
- Phone number is valid and formatted correctly
- SMS gateway credentials are correct
- Account has sufficient balance
- Number is not in DND (Do Not Disturb) list
- Check spam/block lists
- Verify sender ID is approved
Invalid Phone Number
Invalid Phone Number
Solution:
- Use international format (+1234567890)
- Include country code
- Remove spaces and special characters
- Validate before sending
High SMS Costs
High SMS Costs
Optimize:
- Use shorter messages
- Implement rate limiting
- Cache OTPs to prevent resends
- Set cooldown periods
- Monitor for abuse
Gateway API Errors
Gateway API Errors
Debug:
- Check API credentials
- Verify endpoint URLs
- Review error codes in logs
- Test with gateway’s test numbers
- Check account status and balance
Security Best Practices
Compliance
GDPR Compliance
- Obtain consent before sending marketing SMS
- Provide opt-out mechanism
- Store phone numbers securely
- Allow users to delete their data
TCPA Compliance (USA)
- Get explicit consent for SMS
- Include opt-out instructions
- Maintain do-not-contact lists
- Send only during reasonable hours
Alternative: Email OTP
For cost savings, use email OTP as fallback:Related Documentation
Social Login
Configure social authentication
Email Configuration
Setup email notifications