[REBOL] CGI Error Re:(3)

2000-05-17 Thread icimjs

Hi Louis,

a little off-topic, but it is more efficient to collect your output in a
string and print the complete string in one go, using a single call to
print. Like so:

output: make string! 1000

insert output {Content-Type: text/html^/^/
htmlbodyh2Results:/h2}

cgi: make system/standard/email decode-cgi system/options/cgi/query-string

either all [
 email? try [cgi/to: load cgi/to]
 email? try [cgi/from: load cgi/from]
][
 append output "B Sending Email to cgi/to /B"
 send/header cgi/to cgi/content cgi
][
 append output  "BInvalid email to or from address/B"
]

print [output "/bodyhtml"]




At 07:32 PM 5/17/00 -0500, you wrote:
Here's the script:

#!rebol -cs

REBOL [
 Title: "Sends Email via CGI Form"
 Date:  20-July-1999
 File:  %cgiemailer.r
 Purpose: {
 Uses a Web form to send an email message.
 }
]

print "Content-Type: text/html^/^/"  ;-- Required Page Header

print "htmlbodyh2Results:/h2"

cgi: make system/standard/email decode-cgi system/options/cgi/query-string

either all [
 email? try [cgi/to: load cgi/to]
 email? try [cgi/from: load cgi/from]
][
 print [B "Sending Email to" cgi/to /B]
 send/header cgi/to cgi/content cgi
][
 print "BInvalid email to or from address/B"
]

print "/bodyhtml"

And here is the HTML:


HTML

HEAD
 META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"
 TITLEuntitled/TITLE
/HEAD

BODY BGCOLOR="white"

FORM ACTION="http://worldmerchantltd.com/www/cgi-bin/cgiemailer.r" 
METHOD="GET"
H2FONT FACE="Arial, Helvetica"Send an Email Message:/FONT/H2
P
TABLE BORDER="1" CELLSPACING="1" WIDTH="75%" BGCOLOR="silver"
 TR
 TD WIDTH="9%" BGCOLOR="#3C6F99"
 P ALIGN="RIGHT"BFONT COLOR="white"To:/FONT/B
 /TD
 TDINPUT TYPE="TEXT" NAME="to" SIZE="40"/TD
 /TR
 TR
 TD WIDTH="9%" BGCOLOR="#3C6F99"
 P ALIGN="RIGHT"BFONT COLOR="white"From:/FONT/B
 /TD
 TDINPUT TYPE="TEXT" NAME="from" SIZE="40"/TD
 /TR
 TR
 TD WIDTH="9%" BGCOLOR="#3C6F99"
 P ALIGN="RIGHT"BFONT COLOR="white"Subject:/FONT/B
 /TD
 TDINPUT TYPE="TEXT" NAME="subject" SIZE="40"/TD
 /TR
 TR
 TD WIDTH="9%" BGCOLOR="#3C6F99"
 P ALIGN="RIGHT"BFONT COLOR="white"Message:/FONT/B
 /TD
 TDTEXTAREA NAME="content" ROWS="10" COLS="40"/TEXTAREA/TD
 /TR
/TABLE
/P

PINPUT TYPE="SUBMIT" NAME="Submit" VALUE="Send Message"
/FORM

/BODY

/HTML

At 04:07 PM 5/17/00 -0700, you wrote:
Louis wrote:
  CGI Error
  The specified CGI application misbehaved by not returning a complete 
 set of
  HTTP headers. The headers it did return are:

Is your script printing a Content-type header as the first thing it
does, followed by a blank line?

print "Content-type: text/html^/^/"

Kev


Kevin McKinnon, Network Engineer [EMAIL PROTECTED]
Sunshine Communications http://www.sunshinecable.com

PGP Public Key: http://www.dockmaster.net/pgp.html   PGP 6.0 www.pgp.com




;- Elan  [: - )]




[REBOL] CGI Error Re:(3)

2000-05-17 Thread news . ted

 print "/bodyhtml"

This should be /html - but that would not have caused the error you
reported.

Here's a generic email script that I've been using. The form uses the
same variable names you see here (TO, FROM, SUBJECT). Note that you can
add variables in the form, and REBOL will automatically be appended
them to the content. The thing I've been meaning to add is a way to
redirect the user to a confirmation page from the HTML form.

--

#!/usr/bin/rebol --cgi
REBOL[Title: "Contact CGI" ]

;- Configure Internet Mail, if necessary
; set-net [ ] 

;- Create object based on system/standard/email with usual defaults.
;- (!) Added FROM_NAME for personal name
email-obj!: make object! [
TO: none
CC: none
BCC: none
FROM: none
FROM_NAME: none
REPLY-TO: none
DATE: none
SUBJECT: none
RETURN-PATH: none
ORGANIZATION: ""
MESSAGE-ID: none
COMMENT: none
X-REBOL: {2.2.0.3.1 "The Internet Messaging Language (TM)
WWW.REBOL.COM"}
MIME-VERSION: none
CONTENT-TYPE: none
CONTENT: none

]

;- Retrieve HTML form variables from either CGI Environment or Standard
Input
email-obj: make email-obj! decode-cgi either
system/options/cgi/request-method = "GET"
[system/options/cgi/query-string] [make string! input]

;- Tweak email object
set in email-obj 'FROM to-string join email-obj/FROM_NAME [" "
email-obj/FROM ""]
set in email-obj 'REPLY-TO email-obj/FROM
set in email-obj 'SUBJECT join "[CONTACT] " email-obj/SUBJECT
;- (!) Work around bug in send - skips first line of CONTENT thinking
it's the SUBJECT
set in email-obj 'CONTENT join email-obj/SUBJECT [crlf
email-obj/CONTENT]

;- Send it - Message is in email-obj
send/header to-email email-obj/TO "" email-obj

;- Confirm it
print {Content-Type: text/html

!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"
html
head
!-- base href="" --
titleContact Confirmed/title
body
p align=centerThank you for contacting us./p
/body
/html
}
;- END OF PRINT

;- Done
quit



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/