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

Modified to use Outlook Mail Servers #32

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions mail/mail.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package mail

import (
"bytes"
"fmt"
"net/smtp"
"os"
"fmt"
"gopkg.in/gomail.v2"
)

func SendMail(name string, to string, authCode string) error {

/* Old Mail function for IIT K Mail Servers
from := os.Getenv("EMAIL_ID")
password := os.Getenv("EMAIL_PASS")

Expand Down Expand Up @@ -37,4 +37,29 @@ func SendMail(name string, to string, authCode string) error {
return err
}
return nil
*/

from := os.Getenv("EMAIL_ID")
password := os.Getenv("EMAIL_PASS")

// // smtp server configuration.
smtpHost := "smtp-mail.outlook.com"
smtpPort := 587

subject := "Puppy Love Authentication Code"
body := "<!DOCTYPE html><html><style>.container{font-size: large;}body{font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;}code{padding: 6px;background-color: antiquewhite;border-radius: 5px;}</style><body><div class='container'>Hello" + name + ",\nThis is your <code>"+ authCode+ "</code> for Puppy Love.</div></body></html>"

mail_server := gomail.NewMessage()
mail_server.SetHeader("From", from)
mail_server.SetHeader("To", to)
mail_server.SetHeader("Subject", subject)
mail_server.SetBody("text/plain", body)

client := gomail.NewDialer(smtpHost, smtpPort, from, password)
if err := client.DialAndSend(mail_server); err != nil {
fmt.Println("Error Sending Mail: ", err)
return err
}

return nil
}
1 change: 1 addition & 0 deletions puppylove_entity_data.json

Large diffs are not rendered by default.