473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

email send issues

Hi,
Ive producd code to send an email after capturing info off a form,it works fine locally but when i put it live it doesnt work! the code is stopin at 'msg.send' any ideas,

here the code!





Expand|Select|Wrap|Line Numbers
  1. <%
  2. option explicit
  3.  
  4. '---------------------------------------------------------------------------------------------------
  5. 'FORM MAIL SCRIPT
  6. '----------------
  7. 'usage:
  8. '<form ACTION="sendmail_cdo.asp" ...>
  9. '
  10. 'hidden fields:
  11. '    redirect    - the url to redirect to when the mail has been sent (REQUIRED)
  12. '    mailto        - the email address of the recipient (separate multiple recipients with commas)  (REQUIRED)
  13. '    cc            - the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
  14. '    bcc            - the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
  15. '    mailfrom    - the email address of the sender  (REQUIRED)
  16. '    subject        - the subject line of the email  (REQUIRED)
  17. '    message        - the message to include in the email above the field values. not used when a template is being used. (OPTIONAL)
  18. '    template    - specifies a text or html file to use as the email template, relative to the location of the sendmail script. (e.g. ../email.txt)
  19. '                  A template should reference form fields like this: [$Field Name$]
  20. '    html        - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
  21. '    testmode    - if this is set to "yes", the email contents will be written to the screen instead of being emailed.
  22. '---------------------------------------------------------------------------------------------------
  23. dim pde : set pde = createobject("scripting.dictionary")
  24. '---------------------------------------------------------------------------------------------------
  25. 'PREDEFINED ADDRESSES for the "mailto" hidden field
  26. 'if you don't want to reveal email addresses in hidden fields, use a token word instead and specify
  27. 'below which email address it applies to. e.g. <input type="hidden" name="mailto" value="%stratdepartment%">
  28. 'ALSO, in the same way, you can use %mailfrom% to hide the originating email address
  29. pde.add "%contactform%", "kenny.norris@257oops.com"
  30. pde.add "%salesenquiry%", "dave@257oops.com"
  31. '---------------------------------------------------------------------------------------------------
  32.  
  33. function getTextFromFile(path)
  34.     dim fso, f, txt
  35.     set fso = createobject("Scripting.FileSystemObject")
  36.     if not fso.fileexists(path) then
  37.         getTextFromFile = ""
  38.         exit function
  39.     end if
  40.     set f = fso.opentextfile(path,1)
  41.     if f.atendofstream then txt = "" else txt = f.readall
  42.     f.close
  43.     set f = nothing
  44.     set fso = nothing
  45.     getTextFromFile = txt
  46. end function
  47.  
  48. dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
  49. redir = request.form("redirect")
  50. mailto = request.form("mailto")
  51. if pde.exists(mailto) then mailto = pde(mailto)
  52. cc = request.form("cc")
  53. bcc = request.form("bcc")
  54. mailfrom = request.form("mailfrom")
  55. if mailfrom = "" then mailfrom = pde("%mailfrom%")
  56. subject = request.form("subject")
  57. message = request.form("message")
  58. template = request.form("template")
  59. testmode = lcase(request.form("testmode"))="no"
  60.  
  61. if len(template) > 0 then template = getTextFromFile(server.mappath(template))
  62. if len(template) > 0 then usetemplate = true else usetemplate = false
  63. dim msg : set msg = server.createobject("CDO.Message")
  64. msg.subject = subject
  65. msg.to = mailto
  66. msg.from = mailfrom
  67. if len(cc) > 0 then msg.cc = cc
  68. if len(bcc) > 0 then msg.bcc = bcc
  69.  
  70. if not usetemplate then
  71.     body = body & message & vbcrlf & vbcrlf
  72. else
  73.     body = template
  74. end if
  75. for each item in request.form
  76.     select case item
  77.         case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
  78.         case else
  79.             if not usetemplate then
  80.                 if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
  81.             else
  82.                 body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
  83.             end if
  84.     end select
  85. next
  86.  
  87. if usetemplate then 
  88.     dim rx : set rx = new regexp
  89.     rx.pattern = "\[\$.*\$\]"
  90.     rx.global = true
  91.     body = rx.replace(body, "")
  92. end if
  93.  
  94. if usetemplate and lcase(request.form("html")) = "yes" then
  95.     msg.htmlbody = body
  96. else
  97.     msg.textbody = body 
  98. end if
  99. if testmode then
  100.     if lcase(request.form("html")) = "yes" then
  101.         response.write "<pre>" & vbcrlf
  102.         response.write "Mail to: " & mailto & vbcrlf
  103.         response.write "Mail from: " & mailfrom & vbcrlf
  104.         if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
  105.         if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
  106.         response.write "Subject: " & subject & vbcrlf & string(80,"-") & "</pre>"
  107.         response.write body
  108.     else
  109.  
  110.         response.write "<html><head><title>Sendmail_cdo.asp Test Mode</title></head><body><pre>" & vbcrlf
  111.         response.write "Mail to: " & mailto & vbcrlf
  112.         response.write "Mail from: " & mailfrom & vbcrlf
  113.         if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
  114.         if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
  115.         response.write "Subject: " & subject & vbcrlf & vbcrlf
  116.         response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
  117.         response.write body & "</span>" & vbcrlf & vbcrlf
  118.         response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
  119.     end if
  120. else
  121.  
  122.     msg.Send
  123.     response.redirect redir
  124.  
  125.  
  126. end if
  127. set msg = nothing
  128. %>
Oct 10 '07 #1
2 2459
epots9
1,351 Expert 1GB
that is asp, there is no javascript.

the issue could be with the SMTP server.
Oct 10 '07 #2
what could the problem be?been trying to sort it out for days!! help!!
Oct 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Silver | last post by:
I have a perl script running on machine A, a web server. A visitor completes certain pieces of data and these are compiled into two emails, one addressed to the visitor and copied to the site...
1
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is...
7
by: Susan Bricker | last post by:
I would like to generate a report (I have the report working already) using MS/ACCESS 2000 and then have the ability to send the report as an email attachment to my colleagues. I have looked...
2
by: Ron | last post by:
hi guys, I am trying to send email using smtpMail. I can send emails inside the organization, but out of the organization I get an error "The server rejected one or more recipient addresses. The...
0
by: Corvus | last post by:
Hi, we have an ASP.Net web application where users fill out a questionnaire and the the application emails them an employment report. The customer requires the report be sent as an email, so we...
2
by: Dave | last post by:
I have a form on my ASP 3.0 web site and I need to monitor submissions. Is it possible to generate an email upon form submission? If so, how do I invoke the email functionality from an ASP 3.0...
10
by: Jed | last post by:
I have a form that needs to handle international characters withing the UTF-8 character set. I have tried all the recommended strategies for getting utf-8 characters from form input to email...
1
by: Homer | last post by:
Hi, I just got a requirement from my HR department to automate their form submission process and integrate it into the Intranet project that I had just completed Phase 1 of. Because of the...
3
by: shansivamani | last post by:
using SMTP to send email. is there any settings need to be configured apart from Host name and Port, while sending emails using SMTPClient in .Net? when i try to send mail to ids which has only...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.