ASP / CDOSYS - Performance issue

Reply

Join Date: May 2008
Posts: 1
Reputation: worldofrugs is an unknown quantity at this point 
Solved Threads: 0
worldofrugs worldofrugs is offline Offline
Newbie Poster

ASP / CDOSYS - Performance issue

 
0
  #1
May 1st, 2008
I'm hosted on a shared server with Godaddy.com... I have several forms on my website that all use the same ASP file to send out my forms..
It worked fine for a long time, but now the forms send to my e-mail arrive after a few hours instead of instantly.
Calling Godaddy did not help as they stated all is working fine (no delays) on their end and refuse to help with custom scripts..

My emails are also hosted by godaddy like my website.

Hopefully someone here can have a look at my code and see why I might have such huge delays?
Note:
The delays seem to happen when using CDOSYS... I'm also setting up a shopping cart (ProductCart) and when using the CDOSYS function for their email script it has also a huge delay, while setting it to CDO it arrives within minutes...
I do not get any errors, all seems to go fine and mail does arrive after a few hours.

Here's the code (personal info marked out of cos):
  1. <%
  2. option explicit
  3. dim pde : set pde = createobject("scripting.dictionary")
  4.  
  5. pde.add "%mailing%", "email1@myserver.com"
  6. pde.add "%webmaster%", "email2@myserver.com"
  7. pde.add "%info%", "email3@myserver.com"
  8. pde.add "%email%", "email4@myserver.com"
  9.  
  10. function getTextFromFile(path)
  11. dim fso, f, txt
  12. set fso = createobject("Scripting.FileSystemObject")
  13. if not fso.fileexists(path) then
  14. getTextFromFile = ""
  15. exit function
  16. end if
  17. set f = fso.opentextfile(path,1)
  18. if f.atendofstream then txt = "" else txt = f.readall
  19. f.close
  20. set f = nothing
  21. set fso = nothing
  22. getTextFromFile = txt
  23. end function
  24.  
  25. dim redir, mailto, email, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
  26. redir = request.form("redirect")
  27. mailto = request.form("mailto")
  28. if pde.exists(mailto) then mailto = pde(mailto)
  29. cc = request.form("cc")
  30. bcc = request.form("bcc")
  31. email = request.form("email")
  32. if email = "" then email = pde("%email%")
  33. subject = request.form("subject")
  34. message = request.form("message")
  35. template = request.form("template")
  36. testmode = lcase(request.form("testmode"))="no"
  37.  
  38. if len(template) > 0 then template = getTextFromFile(server.mappath(template))
  39. if len(template) > 0 then usetemplate = true else usetemplate = false
  40. dim msg : set msg = server.createobject("CDO.Message")
  41. msg.subject = subject
  42. msg.to = mailto
  43. msg.from = email
  44. if len(cc) > 0 then msg.cc = cc
  45. if len(bcc) > 0 then msg.bcc = bcc
  46.  
  47. if not usetemplate then
  48. body = body & message & vbcrlf & vbcrlf
  49. else
  50. body = template
  51. end if
  52. for each item in request.form
  53. select case item
  54. case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
  55. case else
  56. if not usetemplate then
  57. if item <> "email" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
  58. else
  59. body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
  60. end if
  61. end select
  62. next
  63.  
  64. if usetemplate then 'remove any leftover placeholders
  65. dim rx : set rx = new regexp
  66. rx.pattern = "\[\$.*\$\]"
  67. rx.global = true
  68. body = rx.replace(body, "")
  69. end if
  70.  
  71. if usetemplate and lcase(request.form("html")) = "yes" then
  72. msg.htmlbody = body
  73. else
  74. msg.textbody = body
  75. end if
  76. if testmode then
  77. if lcase(request.form("html")) = "yes" then
  78. response.write "<pre>" & vbcrlf
  79. response.write "Mail to: " & mailto & vbcrlf
  80. response.write "Mail from: " & email & vbcrlf
  81. if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
  82. if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
  83. response.write "Subject: " & subject & vbcrlf & string(80,"-") & "</pre>"
  84. response.write body
  85. else
  86. response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
  87. response.write "Mail to: " & mailto & vbcrlf
  88. response.write "Mail from: " & email & vbcrlf
  89. if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
  90. if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
  91. response.write "Subject: " & subject & vbcrlf & vbcrlf
  92. response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
  93. response.write body & "</span>" & vbcrlf & vbcrlf
  94. response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
  95. end if
  96. else
  97. msg.send
  98. response.redirect redir
  99. end if
  100. set msg = nothing
  101. %>

I also tried adding these lines (and combinations) without any better results:

  1. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  2. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
  3. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 3535
  4. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =1
  5. msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "email1@myserver.com"
  6. msg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "abc1234"

Here's a sample of what's used in the forms:

  1. <form action="/sendmail_cdo.asp" method="post" name="SampleForm" id="SampleForm">
  2. <input type="hidden" name="redirect" value="http://www.myserver.com/thanks.htm">
  3. <input name="mailto" type="hidden" id="mailto" value="%webmaster%">
  4. <input name="subject" type="hidden" id="subject" value="Website Form Submission: Sample form from website">

In the html template used with the form, I use [$form_fieldname$] to display the values entered in the forms.


Anyone any ideas why there might be this huge delay and/or does anyone know how to change this to CDO instead of CDOSYS (as this worked for the shopping cart)?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC