This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed testing that was broken from the SMTP changes.
- Loading branch information
1 parent
8bd5d5d
commit bd00852
Showing
6 changed files
with
10 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1 @@ | ||
package controller | ||
|
||
import ( | ||
"fmt" | ||
"github.com/pkg/errors" | ||
"net/smtp" | ||
) | ||
|
||
func (c *Controller) sendEmailVerification(emailAddress, code string) error { | ||
conf := c.configuration.SMTP | ||
auth := smtp.PlainAuth( | ||
conf.Identity, | ||
conf.Username, | ||
conf.Password, | ||
conf.Host, | ||
) | ||
|
||
to := []string{emailAddress} | ||
from := "[email protected]" | ||
msg := []byte(fmt.Sprintf("To: %s\r\n"+ | ||
"From: no-reply\r\n"+ | ||
"Subject: Please Verify Your Email Address\r\n"+ | ||
"\r\n"+ | ||
"Click the link to verify your account: %s/registration/verify?token=%s\r\n", | ||
emailAddress, | ||
c.configuration.UIDomainName, | ||
code, | ||
)) | ||
address := fmt.Sprintf("%s:%d", conf.Host, conf.Port) | ||
if err := smtp.SendMail(address, auth, from, to, msg); err != nil { | ||
return errors.Wrap(err, "failed to send email") | ||
} | ||
|
||
return nil | ||
} |