Skip to content

Commit

Permalink
fix: use post instead of get
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Dec 6, 2024
1 parent 9fe5b1e commit 2c1a759
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ type MailerConfiguration struct {
// EXPERIMENTAL: May be removed in a future release.
EmailValidationExtended bool `json:"email_validation_extended" split_words:"true" default:"false"`
EmailValidationServiceURL string `json:"email_validation_service_url" split_words:"true"`
EmailValidationServiceHeaders string `json:"email_validation_service_key" split_words:"true"`
EmailValidationServiceHeaders string `json:"email_validation_service_headers" split_words:"true"`

serviceHeaders map[string][]string `json:"-"`
}
Expand All @@ -414,7 +414,7 @@ func (c *MailerConfiguration) Validate() error {
if c.EmailValidationServiceHeaders != "" {
err := json.Unmarshal([]byte(c.EmailValidationServiceHeaders), &headers)
if err != nil {
return fmt.Errorf("conf: SMTP headers not a map[string][]string format: %w", err)
return fmt.Errorf("conf: mailer validation headers not a map[string][]string format: %w", err)
}
}

Expand Down
5 changes: 3 additions & 2 deletions internal/mailer/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (ev *EmailValidator) validateService(ctx context.Context, email string) err
}

rdr := bytes.NewReader(reqData)
req, err := http.NewRequestWithContext(ctx, "GET", ev.serviceURL, rdr)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, ev.serviceURL, rdr)
if err != nil {
return nil
}
Expand All @@ -218,7 +218,8 @@ func (ev *EmailValidator) validateService(ctx context.Context, email string) err
Valid *bool `json:"valid"`
}{}

if res.StatusCode != http.StatusOK {
if res.StatusCode/100 != 2 {
// we ignore the error here just in case the service is down
return nil
}

Expand Down

0 comments on commit 2c1a759

Please sign in to comment.