NewEmailOTPSender (twofactor/otp_sender.go)

iota-sdk · modules/core/services/twofactor/otp_sender.go · go · Apache-2.0
email

Provides a unified interface for sending OTP codes via SMTP email and Twilio SMS services with multi-language support.

// Source: https://github.com/iota-uz/iota-sdk | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Package twofactor provides this package.
package twofactor

import (
	"context"
	"crypto/tls"
	"errors"
	"fmt"
	"net"
	"net/smtp"
	"time"

	"github.com/iota-uz/iota-sdk/pkg/composables"
	"github.com/iota-uz/iota-sdk/pkg/serrors"
	pkgtf "github.com/iota-uz/iota-sdk/pkg/twofactor"
	"github.com/twilio/twilio-go"
	twilioApi "github.com/twilio/twilio-go/rest/api/v2010"
)

// EmailOTPSender sends OTP codes via email using SMTP with STARTTLS.
type EmailOTPSender struct {
	host     string
	port     int
	username string
	password string
	from     string
}

// NewEmailOTPSender creates an Email

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key