Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SMTPConfig ¶
type SMTPConfig struct { FromName string FromAddress string SMTPUsername string SMTPPassword string SMTPServer string SMTPPort int TestAPIPort int }
SMTPConfig represents the configuration for the SMTP email service. It contains the sender's name, address, SMTP username, password, server and port. The TestAPIPort is used to define the port of the API service used for testing the email service locally to check messages (for example using MailHog).
type SMTPEmail ¶
type SMTPEmail struct {
// contains filtered or unexported fields
}
SMTPEmail is the implementation of the NotificationService interface for the SMTP email service. It contains the configuration and the SMTP auth. It uses the net/smtp package to send emails.
func (*SMTPEmail) FindEmail ¶
FindEmail searches for an email in the test API service. It sends a GET request to the search endpoint with the recipient's email address as a query parameter. If the email is found, it returns the email body and clears the inbox. If the email is not found, it returns an EOF error. If the request fails, it returns an error with the status code. This method is used for testing the email service.
func (*SMTPEmail) New ¶
New initializes the SMTP email service with the configuration. It sets the SMTP auth if the username and password are provided. It returns an error if the configuration is invalid or if the from email could not be parsed.
func (*SMTPEmail) SendNotification ¶
func (se *SMTPEmail) SendNotification(ctx context.Context, notification *notifications.Notification) error
SendNotification sends an email notification to the recipient. It composes the email body with the notification data and sends it using the SMTP server.