package email import ( "context" "fmt" "os" "github.com/resend/resend-go/v2" ) type Service struct { client *resend.Client } func NewService() *Service { apiKey := os.Getenv("RESEND_API_KEY") if apiKey == "" { panic("RESEND_API_KEY environment variable is required") } client := resend.NewClient(apiKey) return &Service{client: client} } func (s *Service) SendVerificationCode(ctx context.Context, email, username, code string) error { params := &resend.SendEmailRequest{ From: "noreply@termbox.keircn.com", To: []string{email}, Subject: "Verify your Termbox account", Html: fmt.Sprintf(`
Please verify your account with the following code:
This code will expire in 10 minutes.
If you didn't create an account, please ignore this email.
`, username, code), Text: fmt.Sprintf(` Welcome to Termbox, %s! Please verify your account with the following code: %s This code will expire in 10 minutes. If you didn't create an account, please ignore this email. `, username, code), } _, err := s.client.Emails.Send(params) return err }