패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.2.0

email_otp

빠르고 간단한 이메일 인증용 OTP 전송 및 검증을 위한 플러터 패키지입니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
1.9천
좋아요
115
Pub 점수
160

패키지 설치

flutter pub add email_otp

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

사용자 인증을 간소화하기 위해 이메일 기반의 일회용 비밀번호(OTP)를 보내고 검증하는 가벼운 플러터 패키지입니다. 최소한의 설정으로 이메일 OTP 흐름을 빠르게 통합할 수 있으며, 안드로이드, iOS, 맥OS, 윈도우, 리눅스 등 여러 플랫폼을 지원합니다. OTP 생성 및 검증에 대한 백엔드 통신을 처리하여 안전한 로그인 시스템 개발 시간을 단축시킵니다. 보안성 있는 비밀번호 없는 로그인 또는 계정 확인이 필요한 앱에 적합합니다.

사용 사례

  • 비밀번호 없는 로그인
  • 계정 확인
  • 안전한 사용자 인증
  • 이중 인증
  • 잊어버린 비밀번호 재설정

주요 기능

  • 간단한 OTP 생성
  • 이메일 기반 인증
  • 크로스 플랫폼 지원
  • 최소한의 보일러플레이트 코드
  • Firebase 또는 사용자 지정 백엔드와의 간편한 통합

적합한 대상

  • 보안 인증을 구축하는 개발자
  • 빠른 OTP 워크플로우가 필요한 앱
  • 이메일을 주요 정체성으로 사용하는 프로젝트
  • 빠른 기능 배포를 우선시하는 스타트업
  • 복잡한 인증 인프라를 피하는 팀

고려 사항

  • OTP 처리를 위한 백엔드 서비스가 필요합니다
  • 신뢰할 수 있는 이메일 전달에 의존
  • 고량의 거래 이메일에 적합하지 않습니다
  • 생산 환경에서는 레이트 제한이 필요할 수 있습니다
  • 사용자 경험은 이메일 제공업체의 신뢰성에 달려 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Email OTP is a Flutter package designed to simplify email authentication using one-time passwords (OTPs). With Email OTP, you can effortlessly generate OTPs and send them to users' email addresses, ensuring secure identity verification. This package offers an efficient and secure method for incorporating email-based OTP authentication into your Flutter applications.

Email OTP Banner

GitHub Sponsor

Table of Contents

Configuration

The simplest way to 🛠️ configure the EmailOTP package is by calling the config method.

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

SMTP Configuration (Required)

⚠️ IMPORTANT: As of version 3.1.0, this package no longer uses a default server. You MUST configure your own SMTP server to send emails.

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

Note: For Gmail, use an App Password if 2-Step Verification is enabled.

Advanced Configuration

For more control over the OTP generation and email settings, you can pass various parameters to the config method.

void main() {
  EmailOTP.config(
    appName: 'App Name',
    otpType: OTPType.numeric,
    expiry : 30000,
    emailTheme: EmailTheme.v6,
    appEmail: 'me@rohitchouhan.com',
    otpLength: 6,
    headers: {
      'Reply-To': 'support@rohitchouhan.com'
    }
  );
}

Parameters

  1. host: The hostname of your SMTP server.
  2. emailPort: The port number used by the SMTP server. Supported values include:
    • EmailPort.port25
    • EmailPort.port465
    • EmailPort.port587
    • EmailPort.port1025 (For MailHog/Local Testing)
  3. secureType: The type of security used by the SMTP server. Supported values include:
    • SecureType.none
    • SecureType.tls
    • SecureType.ssl
  4. username: The username for your SMTP server account.
  5. password: The password for your SMTP server account.

By configuring these parameters, you can ensure that your application is able to send OTP emails securely and efficiently.

Themes

Theme Theme Preview
EmailTheme.v1
EmailTheme.v2
EmailTheme.v3
EmailTheme.v4
EmailTheme.v5
EmailTheme.v6
EmailTheme.v7
EmailTheme.v8
EmailTheme.v9
EmailTheme.v10

Template (Optional)

You can also customize the email 🌐 template used to send the OTP. Use the setTemplate method to provide your own HTML template.

void main() {
  EmailOTP.config();
  EmailOTP.setTemplate(
    template: '''
    <div style="background-color: #f4f4f4; padding: 20px; font-family: Arial, sans-serif;">
      <div style="background-color: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);">
        <h1 style="color: #333;">{{appName}}</h1>
        <p style="color: #333;">Your OTP is <strong>{{otp}}</strong></p>
        <p style="color: #333;">This OTP is valid for 5 minutes.</p>
        <p style="color: #333;">Thank you for using our service.</p>
      </div>
    </div>
    ''',
  );
}

Parameters

  • template: A string containing the HTML content of your custom email template. Use placeholders such as {{appName}} and {{otp}} to dynamically insert the application name and OTP respectively.

By configuring these parameters and using a custom template, you can ensure that your OTP emails are tailored to match your application's branding and style.

Sending OTP

To 📧 send an 🔐 OTP to a user's email address, use the sendOTP method. This method takes the recipient's email address as a parameter.

  bool isSent = await EmailOTP.sendOTP(email: emailController.text);
  if (!isSent) {
    print(EmailOTP.lastError); // Prints specific error (e.g. SMTP Auth failed)
  }

Parameters

  • email: The recipient's email address where the OTP will be sent.

Resending OTP

If a user requests a new OTP because they didn't receive the first one, you can use resendOTP instead of generating a new one. This will re-send the existing valid OTP. If it has already expired, a new one will automatically be generated.

  EmailOTP.resendOTP(email: emailController.text);

Verifying OTP

To verify an 🔐 OTP entered by the user, use the verifyOTP method. This method takes the OTP entered by the user as a parameter and returns a boolean indicating whether the OTP is correct.

  EmailOTP.verifyOTP(otp: otpController.text)

Parameters

  • otp: The OTP entered by the user.

Get OTP

This code will print the OTP generated by the getOTP() method.

  print(EmailOTP.getOTP());

Is Expired

This method will helps you to validate your otp expiry time.

  print(EmailOTP.isExpired());

Example

👉 For a complete example, refer to the Email OTP package documentation.

Report bugs or issues

You are welcome to open a ticket on github if any 🐞 problems arise. New ideas are always welcome.

Contributors

Rahul Chouhan
Chouhan Rahul

Copyright © 2024 Rohit Chouhan. Licensed under the MIT LICENSE

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.