25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

82 satır
3.2KB

  1. <%
  2. ' Validates a visitor inquiry and notifies the PostcardMojo team by email.
  3. Class ContactInquiryService_Class
  4. Public Function ValidationErrors(name, email, business, message)
  5. Dim errs : errs = Array()
  6. ReDim errs(-1)
  7. If Len(name) = 0 Then AddMessage errs, "Please enter your name."
  8. If Len(name) > 100 Then AddMessage errs, "Name must be 100 characters or fewer."
  9. If Len(email) = 0 Then
  10. AddMessage errs, "Please enter your email address."
  11. ElseIf Len(email) > 150 Or Not IsValidEmail(email) Then
  12. AddMessage errs, "Please enter a valid email address."
  13. End If
  14. If Len(business) > 150 Then AddMessage errs, "Business name must be 150 characters or fewer."
  15. If Len(message) > 2000 Then AddMessage errs, "Message must be 2000 characters or fewer."
  16. ValidationErrors = errs
  17. End Function
  18. Public Function Notify(name, email, phone, business, message)
  19. Dim recipient, smtpServer, smtpPort, smtpUser, body
  20. recipient = Setting("ContactRecipient", "covington.daniel@gmail.com")
  21. smtpServer = Setting("SmtpServer", "localhost")
  22. smtpPort = Setting("SmtpPort", "25")
  23. smtpUser = Setting("SmtpUsername", "")
  24. body = "New PostcardMojo website inquiry" & vbCrLf & vbCrLf & _
  25. "Name: " & name & vbCrLf & _
  26. "Email: " & email & vbCrLf & _
  27. "Phone: " & phone & vbCrLf & _
  28. "Business: " & business & vbCrLf & vbCrLf & _
  29. "Message:" & vbCrLf & message & vbCrLf & vbCrLf & _
  30. "Received: " & Now() & vbCrLf & _
  31. "IP: " & Request.ServerVariables("REMOTE_ADDR")
  32. CDOEmail.From = Setting("SmtpFrom", Choice(Len(smtpUser) > 0, smtpUser, recipient))
  33. CDOEmail.Subject = "PostcardMojo inquiry from " & StripLineBreaks(name)
  34. CDOEmail.Body = body
  35. CDOEmail.IsBodyHTML = False
  36. CDOEmail.SMTPServer = smtpServer
  37. CDOEmail.SMTPPort = CLng(smtpPort)
  38. CDOEmail.SMTPUsername = smtpUser
  39. CDOEmail.SMTPPassword = EnvService().Value("SMTP_PASSWORD", "")
  40. CDOEmail.SMTPUseSSL = (LCase(Setting("SmtpUseSsl", "false")) = "true")
  41. CDOEmail.AddRecipient "TO", recipient
  42. Notify = CDOEmail.Send()
  43. End Function
  44. Public Function StripLineBreaks(value)
  45. StripLineBreaks = Replace(Replace(value, vbCr, " "), vbLf, " ")
  46. End Function
  47. Private Function Setting(key, fallback)
  48. Dim value : value = GetAppSetting(key)
  49. If value = "nothing" Or Len(value) = 0 Then value = fallback
  50. Setting = value
  51. End Function
  52. Private Function IsValidEmail(value)
  53. Dim re : Set re = New RegExp
  54. re.Pattern = "^[^\s@<>,;""]+@[^\s@<>,;""]+\.[A-Za-z]{2,}$"
  55. IsValidEmail = re.Test(value)
  56. End Function
  57. Private Sub AddMessage(ByRef errs, msg)
  58. ReDim Preserve errs(UBound(errs) + 1)
  59. errs(UBound(errs)) = msg
  60. End Sub
  61. End Class
  62. Dim ContactInquiryService_Class__Singleton
  63. Function ContactInquiryService()
  64. If IsEmpty(ContactInquiryService_Class__Singleton) Then
  65. Set ContactInquiryService_Class__Singleton = New ContactInquiryService_Class
  66. End If
  67. Set ContactInquiryService = ContactInquiryService_Class__Singleton
  68. End Function
  69. %>

Powered by TurnKey Linux.