|
Hi,
using the downloads here I have created a webpage with 4 single line textfields, a list, and a multi line textfield, I also created a template. It all works apart from not returning the multi line textfield data. Any ideas where I am going wrong ?? (using dreamweaver, my first attempt at using a form). Thanks, Steve.
|
|
|
|
|
Where do I insert my smtp server address...?
_____________________________
...and justice for all
APe
|
|
|
|
|
Add the following after msg.from = mailfrom
Dont forget to change 'smtp.server.com'
msg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
msg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="smtp.server.com"
'Server port
msg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25
msg.Configuration.Fields.Update
|
|
|
|
|
Installed this script on a GODADDY server with the minimal ASP support. It doesn;t do anything.
Is this likely some GODADDY restriction?
my (Your) script >>
<%
option explicit
'---------------------------------------------------------------------------------------------------
'FORM MAIL SCRIPT
'----------------
'usage:
'
'
'hidden fields:
' redirect - the url to redirect to when the mail has been sent (REQUIRED)
' mailto - the email address of the recipient (separate multiple recipients with commas) (REQUIRED)
' cc - the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
' bcc - the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
' mailfrom - the email address of the sender (REQUIRED)
' subject - the subject line of the email (REQUIRED)
' message - the message to include in the email above the field values. not used when a template is being used. (OPTIONAL)
' 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)
' A template should reference form fields like this: [$Field Name$]
' html - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
' testmode - if this is set to "yes", the email contents will be written to the screen instead of being emailed.
'---------------------------------------------------------------------------------------------------
dim pde : set pde = createobject("scripting.dictionary")
'---------------------------------------------------------------------------------------------------
'PREDEFINED ADDRESSES for the "mailto" hidden field
'if you don't want to reveal email addresses in hidden fields, use a token word instead and specify
'below which email address it applies to. e.g.
'ALSO, in the same way, you can use %mailfrom% to hide the originating email address
pde.add "%contactform%", "myemail@someaddress.com"
pde.add "%salesenquiry%", "anotheremail@someaddress.com"
'---------------------------------------------------------------------------------------------------
function getTextFromFile(path)
dim fso, f, txt
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(path) then
getTextFromFile = ""
exit function
end if
set f = fso.opentextfile(path,1)
if f.atendofstream then txt = "" else txt = f.readall
f.close
set f = nothing
set fso = nothing
getTextFromFile = txt
end function
dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
redir = request.form("http://www.jmm3.biz/default.html")
mailto = request.form("jmmagruder3@sbcglobal.net")
if pde.exists(mailto) then mailto = pde(mailto)
cc = request.form("cc")
bcc = request.form("bcc")
mailfrom = request.form("email")
if mailfrom = "" then mailfrom = pde("%mailfrom%")
subject = request.form("HELPME")
message = request.form("message")
dayphone = request.form("day")
nightphone = request.form("night")
template = request.form("template")
testmode = lcase(request.form("testmode"))="no"
if len(template) > 0 then template = getTextFromFile(server.mappath(template))
if len(template) > 0 then usetemplate = true else usetemplate = false
dim msg : set msg = server.createobject("CDO.Message")
msg.subject = subject
msg.to = mailto
msg.from = mailfrom
if len(cc) > 0 then msg.cc = cc
if len(bcc) > 0 then msg.bcc = bcc
if not usetemplate then
body = body & message & vbcrlf & vbcrlf
else
body = template
end if
for each item in request.form
select case item
case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode","buyer","seller","fname","lname","day","night","comments"
case else
if not usetemplate then
if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
else
body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf," "))
end if
end select
next
if usetemplate then 'remove any leftover placeholders
dim rx : set rx = new regexp
rx.pattern = "\[\$.*\$\]"
rx.global = true
body = rx.replace(body, "")
end if
if usetemplate and lcase(request.form("html")) = "yes" then
msg.htmlbody = body
else
msg.textbody = body
end if
if testmode then
if lcase(request.form("html")) = "yes" then
response.write "
" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(dayphone) > 0 then response.write "Dayphone: " & day & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & string(80,"-") & " "
response.write body
else
response.write "<title>Sendmail.asp Test Mode
" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
response.write body & "</span>" & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & "**END OF EMAIL** "
end if
else
msg.send
response.redirect redir
end if
set msg = nothing
%>
My html form >
<title>Magruder Web Feedback
<span
style='font-size:20.0pt'> Your Information Will Be Kept CONFIDENTIAL<span
style='font-size:24.0pt'> <span
style='mso-tab-count:1'>
<span
style='font-size:13.5pt'> Please select INTEREST category
<span
style='font-size:18.0pt'>
BUYER
SELLER
<span
style='font-size:13.5pt'>Please provide your email
like abc @hotmail.com
Please provide your
name First
Last
Please provide 1 or more
phones Day<span
style='font-size:13.5pt'>
Night
Please ask a question of state needs
below – PLEASE be specific !
<span
style='mso-tab-count:2'> I will reply as soon as possible. <span
style='mso-spacerun:yes'>
<o:p>
<a
href="http: www.jmm3.biz="" default.html"="">RETURN
Thanks
John
John
|
|
|
|
|
I have been browsing the list, and couldnt find any information on this.
It would be fantastic if there is a way to attach (input type=file) files via form and send through to the specified email using sendmail.
Is this possible?
And if possible, how do I go about doing it?
Thanks!
K
|
|
|
|
|
the sendmail works great is there away instead of sending the form results as an attachment instead of sending them to a html template.
cheers
|
|
|
|
|
i have set up this script on our intranet at work. when i run it in testmode, it does fine, printing the results to my screen. when i use a value of "no" for testmode, it gives me an error with the following info:
Error Type:
CDO.Message.1 (0x80040220)
The "SendUsing" configuration value is invalid.
/sendmail_cdo.asp, line 120
...
Page:
POST 302 bytes to /sendmail_cdo.asp
any help would be greatly appreciated...
|
|
|
|
|
Script works great and is much appreciated.
I was trying to set so could send via our email server rather than installing SMTP on web server.
I found code to do it in a vbs script
but not sure if can use or where to use in this script.
Here was the code...and it does work in the script i took it from...but wanted to use it with this script and the forms.
Any ideas??
Will this work in this script and in place of what?
Thanks in advance
' Send by connecting to port 25 of the SMTP server.
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Const cdoSendUsingPort = 2
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' Set the CDOSYS configuration fields to use port 25 on the SMTP server.
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.0.0.200"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
|
|
|
|
|
I am getting an error that says
"Method Not Allowed
The requested method POST is not allowed for the URL /sendmail_cdo.asp."
I have spent HOURS going over the 2 pages involved in using the sendmail code and am near tears. Can anyone please help me with this? The form is located at www.kodonnellsrestaurant.com/k-odonnells-restaurant-jobs.shtml and the sendmail_cdo.asp file is in the root folder along with the page and the .hmtl template. I got the same error when I used the sendmail.asp file.
Please help!!!
Morgan
|
|
|
|
|
Hi,
From what I understand, you're using a Unix/Linux host. I have no experience with *nix systems, and built this script quite a while ago for Microsoft ASP under IIS on Windows. As far as I am aware though, Linux/Unix won't natively process ASP pages without installing the correct software on the server, in your case it would probably be (I think) Chillisoft ASP.
If you do have an ASP processor for your web hosting you're still going to have a problem because the mail sending aspect of the script uses native Windows components, which to my knowledge, don't exist in any form on Unix or Linux.
I would recommend that you either (a) move to a Windows-based host or (b) hunt for a PHP or CGI sendmail script. Do a search for "PHP form mail script".
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
web/blog: www.ersysgroup.com[^]
|
|
|
|
|
I'm new to ASP and was wondering what i need to add for it send the email to a remote SMTP server.
|
|
|
|
|
This code is great. I'm jsut wondering if there's a way to have multiple mailto: address possible based on a field selected like City or county by the customer so that the request gets sent to the right email for a quick response. We've got regional people that are better suited to receive this requests than just one large email account.
How would I go about something like that. I'm a newbie with ASP too so this has been a great help!
|
|
|
|
|
Since my ISP doesn't support asp (how archaic!), do you have a script which I can use which doesn't need an interpretor? All I am looking for is to jump to an e-mail which is pre-formatted with the form. I prefer not to place the form on the website.
|
|
|
|
|
Hi,
I'm having a problem running this script on our server. I get the following error:
Server object error 'ASP 0177 : 8007007e'
Server.CreateObject Failed
/sendmail_cdo.asp, line 63
8007007e
Line 63 is: dim msg : set msg = server.createobject("CDO.Message")
I'm fairly new to asp so any help to diagnose the problem would be greatly appreciated.
Thanks, Danielle
|
|
|
|
|
Two things:
1) Try the other asp file; it uses a slightly different method of sending mail.
2) If that doesn't work, your hosting provider has disabled your access to the CDO library to prevent you from sending mail.
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
web/blog: www.ersysgroup.com[^]
|
|
|
|
|
Nathan, Thanks for such a wonderful script!!! I do some simple webmastering for some small accounts and have been slowly watching servers drop support for CDONTS -- the script that I WAS using for all the various little web forms. It got so bad that I was finally "cheating" and serving the ASP scripts from my server because it would still support CDONTS. Surprise! They upgraded the servers at my host and suddenly a customer (who gets lots of genuine hits on their forms) contacts me that their customers are complaining of failures. I'm a better debugger than a code writer and I've been looking everywhere for a CDOSYS form mail script that actually worked. I found yours, studied over it, and I've updated 3 forms -- all in 4 hours. THANK YOU, THANK YOU, THANK YOU!!!
Tricia
Patricia S. McDonald
www.tgpgraphics.com
Austell, GA, USA
|
|
|
|
|
Glad it helped
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
web/blog: www.ersysgroup.com[^]
|
|
|
|
|
Just what I needed. This saves me a lot of time from searching for other scripts and writing code myself.
|
|
|
|
|
I'm getting an error on line 53 (mailfrom field, isn't it?) and wanting to know what I enter into the mailfrom field... it's not so clear...
|
|
|
|
|
the mailfrom field is the address that the email to be sent from. Some mail servers require that either "to" address or "from" address be valid mail addresses on the server, so that may be the problem.
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
web/blog: www.ersysgroup.com[^]
|
|
|
|
|
Hi,
Instead of using a text input for the subject line, I'm using the <select> option. My question is, how would I use the Validation in this example to ensure the user selects a different selection then the pre-selected one?
Example:
<select size="1" name="Subject">
<option selected>Please Select a Subject</option>
<option>Consulting Services</option>
<option>General Information</option>
</select>
I want the validate to ensure the user selects something else the nthe default "Please Select a Subject" before being able to send the form.
Any help would be great!
Thank you
|
|
|
|
|
For some reason I'm just getting a blank email message when I submit the form. Obviously it seems to "work" but it doesn't send any content with it.
Any ideas as to why this is?
Here's the code I'm using (I had to modify it to work with CDO):
<code><%
'---------------------------------------------------------------------------------------------------
'FORM MAIL SCRIPT
'----------------
'usage:
'<form ACTION="sendmail.asp" ...>
'
'Hidden fields to use in the form:
' redirect - the url to redirect to when the mail has been sent (REQUIRED)
' mailto - the email address of the recipient (separate multiple recipients with commas) (REQUIRED)
' cc - the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
' bcc - the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
' mailfrom - the email address of the sender (REQUIRED)
' subject - the subject line of the email (REQUIRED)
' message - the message to include in the email above the field values. not used when a template is
' being used. (OPTIONAL)
' 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) Templates should reference form fields like this: [$Field Name$]
' html - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
' testmode - if this is set to "yes", the email contents will be written to the screen instead of being emailed.
'---------------------------------------------------------------------------------------------------
option explicit
function getTextFromFile(path)
dim fso, f, txt
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(path) then
getTextFromFile = ""
exit function
end if
set f = fso.opentextfile(path,1)
if f.atendofstream then txt = "" else txt = f.readall
f.close
set f = nothing
set fso = nothing
getTextFromFile = txt
end function
dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
redir = request.form("redirect")
mailto = request.form("mailto")
cc = request.form("cc")
bcc = request.form("bcc")
mailfrom = request.form("mailfrom")
subject = request.form("subject")
message = request.form("content")
template = request.form("template")
if len(template) > 0 then template = getTextFromFile(server.mappath(template))
if len(template) > 0 then usetemplate = true else usetemplate = false
dim msg : set msg = server.createobject("CDO.Message")
if usetemplate and lcase(request.form("html")) = "yes" then
msg.HTMLbody = html '(html)
' msg.MIMEbody = 0 '(mime)
end if
msg.subject = subject
msg.to = mailto
msg.from = mailfrom
if len(cc) > 0 then msg.cc = cc
if len(bcc) > 0 then msg.bcc = bcc
if not usetemplate then
body = body & message & vbcrlf & vbcrlf
else
body = template
end if
for each item in request.form
select case item
case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
case else
if not usetemplate then
if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
else
body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
end if
end select
next
if usetemplate then 'remove any leftover placeholders
dim rx : set rx = new regexp
rx.pattern = "\[\$.*\$\]"
rx.global = true
body = rx.replace(body, "")
end if
body = body & message
if testmode then
if lcase(request.form("html")) = "yes" then
response.write "<pre>" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & string(80,"-") & "</pre>"
response.write body
else
response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
response.write body & "</span>" & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
end if
else
msg.send
response.redirect redir
end if
set msg = nothing
%>
</code>
- Nick
|
|
|
|
|
the sendmail work great, i was wondering if it is possible to auto reply a copy of the html template to the email mail address entered into the "mailfrom" field.
Richard
|
|
|
|
|
I am wondering the same thing. I love the sendmail but really need to have an auto reply.
|
|
|
|
|
I'm getting this error after changing the "CDONTS" to CDO... to correspond with what I read about CDONTS being outdated now.
Microsoft VBScript runtime error '800a01b6'<br />
<br />
Object doesn't support this property or method: 'body'<br />
<br />
/ims/sendmail/sendmail.asp, line 89
Can you please help??
|
|
|
|
|