package mailmux import ( "errors" ) // User represents a mailmux user. type User struct { // The name should be a valid email address. name string password Password } type Password []byte // A UserStore provides storage and authentication of users. type UserStore interface { // Change creates or updates the named user with the new password. Change(name string, new Password) error // Lookup returns the User with name. // The error should be ErrUnknownUser if the user is not found. Lookup(name string) (User, error) // Delete removes the user from the store. Delete(name string) error // Authenticate authenticates the user identified by username with pw. // error is non-nil if the password is incorrect or on any other error. Authenticate(username string, pw Password) error } type ticket []byte var testTicket = []byte(`TEST NOT REAL`) var ( ErrUserExist = errors.New("user already exists") ErrUnknownUser = errors.New("unknown user") ) // verified checks whether ownership of username's address has // been confirmed. // func (store *astore) verified(username string) (bool, error) { // _, err := store.Lookup(username) // if errors.Is(err, ErrUnknownUser) { // return false, err // } // // _, err = os.Stat(path.Join(store.confirmDir, username)) // if err == nil { // return false, nil // } // if errors.Is(err, fs.ErrNotExist) { // return true, nil // } // return false, fmt.Errorf("check confirm file: %w", err) // } // verify attempts to verify the username using the given token. // func (store *astore) verify(username string, tok token) error { // f, err := os.Open(path.Join(store.confirmDir, username)) // if errors.Is(err, fs.ErrNotExist) { // return ErrUnknownUser // } else if err != nil { // return err // } // defer f.Close() // b, err := io.ReadAll(f) // if err != nil { // return err // } // if bytes.Equal(b, []byte(tok)) { // return os.Remove(path.Join(store.confirmDir, username)) // } // return errors.New("mismatched token") // } func SendConfirmationMail(from, to string, tik ticket) error { return nil // From: $from // To: $to // Subject: Confirm address ownership // // Thanks for signing up to mailmux.net! // Confirm ownership of $address by accessing the following link: // https://mailmux.net/confirm?username=test@example.com&token=abcd12345 // Alternatively, go to https://mailmux.net/confirm // enter your email address and your token: // abcd12345 // // If you have not signed up for mailmux.net, please // let us know by forwarding this mail to abuse@mailmux.net. // Thank you for helping us fight spam! }