Skip to content
pubscout

email_otp

3.2.0, released 5 months ago by rohitchouhan.com

A package to generate, send, and verify one-time passwords via custom SMTP email servers.

$ flutter pub add email_otp
Source repository

What it does

Generates one-time passwords (OTPs) and sends them to user email addresses via a configured SMTP server. Provides built-in templates, verification, resending logic, and expiration tracking.

AI-written summary of version 3.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need custom email-based OTP verification in your app using your own SMTP credentials.
  • You want pre-built responsive HTML email templates for sending authentication codes.

Skip it when

  • You rely on a built-in backend-as-a-service like Firebase or Supabase to manage authentication out-of-the-box.
  • You need to send emails securely without exposing SMTP server configurations in client-side code.

Strengths

  • Supports multiple pre-built HTML templates with light and dark mode.
  • Cryptographically secure OTP generation using Random.secure().
  • Allows custom SMTP configuration and headers.

Weaknesses

  • Requires exposing SMTP server credentials and passwords on the client side since emails are sent directly from the app.
  • Lacks a hosted server backend for centralized rate-limiting or secure token storage.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Requires configuring an SMTP host, port, security type, username, and password using EmailOTP.setSMTP().

EmailOTP.config(
  appName: 'MyApp',
  otpType: OTPType.numeric,
  emailTheme: EmailTheme.v1,
);

EmailOTP.setSMTP(
  host: 'smtp.gmail.com',
  emailPort: EmailPort.port587,
  secureType: SecureType.tls,
  username: 'your-email@gmail.com',
  password: 'your-app-password',
);

bool isSent = await EmailOTP.sendOTP(email: 'user@example.com');
bool isValid = EmailOTP.verifyOTP(otp: '123456');

Alternatives

Packages that do the same job and could replace email_otp.

Works with

Packages commonly used together with email_otp: ones it builds on, ones built on it, and its own family.