diff --git a/main.go b/main.go index f8a96e9..13dece4 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,6 @@ func main() { viper.SetDefault("CONTACT_REPLY_EMAIL", "noreply@company.com") viper.SetDefault("CONTACT_REPLY_BCC_EMAIL", "contact@company.com") viper.SetDefault("EMAIL_SUBJECT", "Thanks to try our product") - viper.SetDefault("DEMO_URL", "http://company.com/product-demo") viper.SetDefault("SMTP_AUTHENTICATION_ENABLED", true) host := os.Getenv("HOST") diff --git a/sendmail.go b/sendmail.go index e85ceb2..cae0fd0 100644 --- a/sendmail.go +++ b/sendmail.go @@ -67,7 +67,7 @@ func NewSendMailRequest(from string, to []string, subject string) *SendMailReque // Execute processes the actual email sending func (m *SendMailRequest) Execute() error { - mime := "MIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n" + mime := "MIME-version: 1.0;\nContent-Type: text/plain; charset=\"UTF-8\";\n\n" from := "From: " + m.from + "\n" subject := "Subject: " + m.subject + "\n" msg := []byte(from + subject + mime + "\n" + m.body) @@ -229,18 +229,7 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) { OriginURI: httpReq.FormValue("requestOrigin"), } - var recipients []string - switch contactRequest.RequestTarget { - case "demo": - recipients = []string{contactRequest.Email, viper.GetString("CONTACT_REPLY_BCC_EMAIL")} - case "contact": - recipients = []string{viper.GetString("CONTACT_REPLY_BCC_EMAIL")} - default: - log.Println("not allowed request type:", contactRequest.RequestTarget) - httpResp.WriteHeader(http.StatusForbidden) - httpResp.Write([]byte(`{"status": "error", "message": "unauthorized request"}`)) - return - } + recipients := []string{viper.GetString("CONTACT_REPLY_BCC_EMAIL")} userData, _ := json.Marshal(contactRequest) log.Println("New Request:", string(userData)) @@ -251,27 +240,17 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) { Organization string Subject string Message string - DemoURL string }{ Name: contactRequest.Name, Email: contactRequest.Email, Organization: contactRequest.Organization, Subject: contactRequest.Subject, Message: contactRequest.Message, - DemoURL: viper.GetString("DEMO_URL"), } - replyTplFile := "" - if contactRequest.RequestTarget == "demo" { - replyTplFile = viper.GetString("TEMPLATE_DEMO_REQUEST_REPLY") - if replyTplFile == "" { - replyTplFile = "./templates/template_reply_demo_request.html" - } - } else { - replyTplFile = viper.GetString("TEMPLATE_CONTACT_REQUEST_REPLY") - if replyTplFile == "" { - replyTplFile = "./templates/template_reply_contact_request.html" - } + replyTplFile := viper.GetString("TEMPLATE_CONTACT_REQUEST_REPLY") + if replyTplFile == "" { + replyTplFile = "./templates/template_reply_contact_request.txt" } contactEmail := viper.GetString("CONTACT_REPLY_EMAIL") @@ -291,11 +270,7 @@ func SendMail(httpResp http.ResponseWriter, httpReq *http.Request) { contactResponse.Message = fmt.Sprintf("An internal error occurred, please try later or send us an email at %s.", viper.GetString("CONTACT_REPLY_BCC_EMAIL")) } else { contactResponse.Status = "success" - if contactRequest.RequestTarget == "demo" { - contactResponse.Message = "Thank you, if you supplied a correct email address then an email should have been sent to you." - } else { - contactResponse.Message = "Thank you, if you supplied a correct email address then we'll process your request within the next 48 hours." - } + contactResponse.Message = "Thank you for your message." } } else { log.Println(err.Error()) diff --git a/templates/template_reply_contact_request.html b/templates/template_reply_contact_request.html deleted file mode 100644 index 1a35a12..0000000 --- a/templates/template_reply_contact_request.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -

Hi,

-

A new contact request has been submitted by Mr/Mrs {{.Name}}.

- --- -

This is an automatic email from Krossboard's website.

- - - - \ No newline at end of file diff --git a/templates/template_reply_contact_request.txt b/templates/template_reply_contact_request.txt new file mode 100644 index 0000000..0fd661b --- /dev/null +++ b/templates/template_reply_contact_request.txt @@ -0,0 +1,12 @@ +Hello, + +A new message has been received on the contact form. + +Name: {{.Name}} +Email: {{.Email}} +Subject: {{.Subject}} + +{{.Message}} + +-- +Automatic email from F5KCK Website diff --git a/templates/template_reply_demo_request.html b/templates/template_reply_demo_request.html deleted file mode 100644 index 8d296eb..0000000 --- a/templates/template_reply_demo_request.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -

Dear Mr/Mrs {{.Name}},

-

-Thank you for your interest in our products. -You'll find below information to get access to the demo platform. -

- - -

Enjoy and don't hesitate to contact us if you do have any feedback.

-

-Kind regards,
-The Customer Service Team -

- -
-Summary of your request - - - - - - \ No newline at end of file