package messenger

import (
	"context"
	"github.com/resend/resend-go/v2"
)

func (s *Service) SendEmail(ctx context.Context, receiverEmail, message string, messageHTML string, subject string) error {
	apiKey := s.config.ResendApiKey
	client := resend.NewClient(apiKey)
	formattedSenderEmail := "Y <" + s.config.ResendSenderEmail + ">"
	params := &resend.SendEmailRequest{
		From:    formattedSenderEmail,
		To:      []string{receiverEmail},
		Subject: subject,
		Text:    message,
		Html:    messageHTML,
	}

	_, err := client.Emails.Send(params)
	if err != nil {
		return err
	}

	return nil
}
