PHP code example of fekharmensour / otp-mailer

1. Go to this page and download the library: Download fekharmensour/otp-mailer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fekharmensour / otp-mailer example snippets



use Fekharmensour\OtpMailer\Facades\OtpMailer;
use Illuminate\Http\Request;

Route::get('/send-otp', function () {
	$email = '[email protected]';
	$code = OtpMailer::generateAndSend($email);

	return "OTP sent to {$email}"; // do not reveal the code in production
});

Route::post('/verify-otp', function (\\Illuminate\\Http\\Request $request) {
	$email = $request->input('email');
	$code = $request->input('code');

	$valid = OtpMailer::validate($email, $code);

	return response()->json(['valid' => $valid]);
});

use Fekharmensour\OtpMailer\Facades\OtpMailer;

public function send(Request $request)
{
	$email = $request->input('email');
	OtpMailer::generateAndSend($email);

	return back()->with('status', 'OTP sent');
}
bash
php artisan vendor:publish --provider="Fekharmensour\OtpMailer\OtpMailerServiceProvider" --tag=config