Download the PHP package fekharmensour/otp-mailer without Composer
On this page you can find all versions of the php package fekharmensour/otp-mailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fekharmensour/otp-mailer
More information about fekharmensour/otp-mailer
Files in fekharmensour/otp-mailer
Package otp-mailer
Short Description Standalone OTP mailer package for Laravel (send OTP codes)
License MIT
Informations about the package otp-mailer
otp-mailer
Standalone OTP mailer package for Laravel — send one-time passwords (OTP) to user emails.
Installation
-
Require the package via Composer:
- (Optional) If your app does not auto-discover packages, register the service provider and alias in
config/app.php:
- Provider:
Fekharmensour\OtpMailer\OtpMailerServiceProvider - Alias:
OtpMailer=>Fekharmensour\OtpMailer\Facades\OtpMailer
Publish configuration
The package ships a config file. Publish it with this command:
This will copy config/otp-mailer.php to your application's config folder. You can also copy config/otp-auth.php from the package if you need the legacy compatibility file.
Environment / SMTP setup
The package sends emails using Laravel's mail system. Add your SMTP credentials to .env. For example (Gmail app password):
Note: For Gmail use an App Password (requires 2FA). Replace your_app_password with that app password.
Usage (simple route)
The package exposes a facade OtpMailer (and backward-compatible OtpAuth). Use generateAndSend(string $email) to create and email a 6-digit OTP, and validate(string $email, string $code) to validate it.
Example route (routes/web.php):
Usage (controller)
In a controller you can call the same facade methods:
Configuration
Open config/otp-mailer.php to change TTL, cache prefix, or the Notification class used to send the email. The default notification class is Fekharmensour\\OtpMailer\\Notifications\\OtpNotification.
Troubleshooting
- Ensure your mail settings in
.envare correct and that the app can send mail (tryphp artisan tinker+\\Mail::raw('test', function($m){$m->to('[email protected]')->subject('test');});). - For Gmail use an App Password and enable the correct security settings.
License
MIT