Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add email validation function to lower bounce rates #1845

Merged
merged 6 commits into from
Dec 5, 2024

Conversation

cstockton
Copy link
Contributor

The goal is to only return an error when we have a very high confidence the email won't be deliverable.

This is currently going to be added as a draft for the team to review. I haven't actually implemented any paths that call this or configuration around when it is activated.

The goal is to only return an error when we have a very high
confidence the email won't be deliverable.
@coveralls
Copy link

coveralls commented Nov 26, 2024

Pull Request Test Coverage Report for Build 12189005080

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 158 of 217 (72.81%) changed or added relevant lines in 7 files are covered.
  • 84 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.3%) to 57.268%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/conf/configuration.go 13 15 86.67%
internal/mailer/noop.go 3 5 60.0%
internal/mailer/mailme.go 0 5 0.0%
internal/api/mail.go 10 17 58.82%
internal/mailer/mailer.go 3 13 23.08%
internal/mailer/validate.go 119 152 78.29%
Files with Coverage Reduction New Missed Lines %
main.go 10 0.0%
cmd/migrate_cmd.go 16 0.0%
internal/api/external.go 58 75.23%
Totals Coverage Status
Change from base Build 11932304745: 0.3%
Covered Lines: 9696
Relevant Lines: 16931

💛 - Coveralls

Copy link
Member

@kangmingtay kangmingtay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed internally, one suggestion would be to add this validation in the sendEmail function (

func (a *API) sendEmail(r *http.Request, tx *storage.Connection, u *models.User, emailActionType, otp, otpNew, tokenHashWithPrefix string) error {
)

internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
@cstockton cstockton marked this pull request as ready for review December 2, 2024 22:28
@cstockton cstockton requested a review from a team as a code owner December 2, 2024 22:28
Copy link
Member

@kangmingtay kangmingtay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in terms of where we should include this validation, i'm thinking it can either be used in:

  1. The validateEmail API struct method (
    func (a *API) validateEmail(email string) (string, error) {
    )
  2. Or in sendEmail, before we make the request to the SMTP server (
    func (a *API) sendEmail(r *http.Request, tx *storage.Connection, u *models.User, emailActionType, otp, otpNew, tokenHashWithPrefix string) error {
    )

internal/mailer/validate.go Show resolved Hide resolved
internal/conf/configuration.go Outdated Show resolved Hide resolved
Copy link
Member

@kangmingtay kangmingtay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a bunch of readability nits that can be cleaned up in a follow up

internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
internal/mailer/validate.go Outdated Show resolved Hide resolved
@cstockton cstockton merged commit 2c291f0 into master Dec 5, 2024
2 checks passed
@cstockton cstockton deleted the cs/feat-validate-email-address branch December 5, 2024 22:49
cstockton pushed a commit that referenced this pull request Dec 5, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.165.0](v2.164.0...v2.165.0)
(2024-12-05)


### Features

* add email validation function to lower bounce rates
([#1845](#1845))
([2c291f0](2c291f0))
* use embedded migrations for `migrate` command
([#1843](#1843))
([e358da5](e358da5))


### Bug Fixes

* fallback on btree indexes when hash is unavailable
([#1856](#1856))
([b33bc31](b33bc31))
* return the error code instead of status code
([#1855](#1855))
([834a380](834a380))
* revert fallback on btree indexes when hash is unavailable
([#1858](#1858))
([1c7202f](1c7202f))
* update ip mismatch error message
([#1849](#1849))
([49fbbf0](49fbbf0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
cstockton pushed a commit to supabase/supabase that referenced this pull request Dec 6, 2024
The purpose of this change is to reduce the bounce back rate of
the default email provider at Supabase. This change will allow
users to continue copying examples from the docs. Without it, an
upcoming change in supabase/auth[1] will begin rejecting these
invalid emails.

[1] supabase/auth#1845
cstockton added a commit to supabase/supabase that referenced this pull request Dec 9, 2024
The purpose of this change is to reduce the bounce back rate of
the default email provider at Supabase. This change will allow
users to continue copying examples from the docs. Without it, an
upcoming change in supabase/auth[1] will begin rejecting these
invalid emails.

[1] supabase/auth#1845

Co-authored-by: Chris Stockton <chris.stockton@supabase.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants