[REBOL] SMTP authentication - the answer - but another question
From: kitson:maxis:my at: 19-Apr-2001 10:49
Hi Scott and Brett,
Thanks for your suggestions - I took it to 'feedback' and got -
> "REBOL does not currently support SMTP authorization though your request
has been added to our protocol enhancement list.
> If you can't possibly wait, the SMTP protocol in REBOL is writtin in REBOL
and can therefore be modified by you or anybody else to support
authorization."
So, being a dog with a bone, I've pasted the results of probing the smtp
scheme below in the hope that somebody better able than I could add the
doubtless 2 or 3 lines of code to make it work. If somebody does take on
the challenge and doesn't have a SMTP server account that requires
authentication, please email me ([kitson--maxis--net--my]) and I can provide
details of a temporary account for testing purposes.
Thanks Rebols!
Nick
>> probe get in system/schemes 'smtp
make object! [
scheme: 'SMTP
host: none
port-id: 25
user: none
pass: none
target: none
path: none
proxy:
make object! [
host: none
port-id: none
user: none
pass: none
type: none
bypass: none
]
access: none
allow: none
buffer-size: none
limit: none
handler:
make object! [
port-flags: 524288
open-check: [none "220" ["HELO" system/network/host] "250"]
close-check: ["QUIT" "221"]
write-check: [none "250"]
init: func [
"Parse URL and/or check the port spec object"
port "Unopened port spec"
spec {Argument passed to open or make (a URL or port-spec)}
/local scheme
][
if url? spec [net-utils/url-parser/parse-url port spec]
scheme: port/scheme
port/url: spec
if none? port/host [
net-error reform ["No network server for" scheme "is
specified"]
]
if none? port/port-id [
net-error reform ["No port address for" scheme "is
specified"]
]
]
open: func [
{Open the socket connection and confirm server response.}
port "Initalized port spec"
/locals sub-port data in-bypass find-bypass bp
][
net-utils/net-log ["Opening tcp for" port/scheme]
if not system/options/quiet [print ["connecting to:" port/host]]
find-bypass: func [host bypass /local x] [
if found? host [
foreach item bypass [
if all [x: find/match/any host item tail? x] [return
true]
]
]
false
]
in-bypass: func [host bypass /local item x] [
if any [none? bypass empty? bypass] [return false]
if not tuple? load host [host: form system/words/read join
dns:// host]
either find-bypass host bypass [
true
] [
host: system/words/read join dns:// host
find-bypass host bypass
]
]
either all [port/proxy/host bp: not in-bypass port/host
port/proxy/bypass find [s
ocks4 socks5 socks] port/proxy/type] [
port/sub-port: net-utils/connect-proxy port 'connect
] [
sub-port: system/words/open/lines [
scheme: 'tcp
host: either all [port/proxy/type = 'generic bp]
[port/proxy/host] [port/
proxy/host: none port/host]
user: port/user
pass: port/pass
port-id: either all [port/proxy/type = 'generic bp]
[port/proxy/port-id]
[port/port-id]
]
port/sub-port: sub-port
]
port/sub-port/timeout: port/timeout
port/sub-port/user: port/user
port/sub-port/pass: port/pass
port/sub-port/path: port/path
port/sub-port/target: port/target
net-utils/confirm/multiline port/sub-port open-check
port/state/flags: port/state/flags or port-flags
]
open-proto: func [
{Open the socket connection and confirm server response.}
port "Initalized port spec"
/locals sub-port data in-bypass find-bypass bp
][
net-utils/net-log ["Opening tcp for" port/scheme]
if not system/options/quiet [print ["connecting to:" port/host]]
find-bypass: func [host bypass /local x] [
if found? host [
foreach item bypass [
if all [x: find/match/any host item tail? x] [return
true]
]
]
false
]
in-bypass: func [host bypass /local item x] [
if any [none? bypass empty? bypass] [return false]
if not tuple? load host [host: form system/words/read join
dns:// host]
either find-bypass host bypass [
true
] [
host: system/words/read join dns:// host
find-bypass host bypass
]
]
either all [port/proxy/host bp: not in-bypass port/host
port/proxy/bypass find [s
ocks4 socks5 socks] port/proxy/type] [
port/sub-port: net-utils/connect-proxy port 'connect
] [
sub-port: system/words/open/lines [
scheme: 'tcp
host: either all [port/proxy/type = 'generic bp]
[port/proxy/host] [port/
proxy/host: none port/host]
user: port/user
pass: port/pass
port-id: either all [port/proxy/type = 'generic bp]
[port/proxy/port-id]
[port/port-id]
]
port/sub-port: sub-port
]
port/sub-port/timeout: port/timeout
port/sub-port/user: port/user
port/sub-port/pass: port/pass
port/sub-port/path: port/path
port/sub-port/target: port/target
net-utils/confirm/multiline port/sub-port open-check
port/state/flags: port/state/flags or port-flags
]
close: func [
{Quit server, confirm and close the socket connection}
port "An open port spec"
][
port: port/sub-port
net-utils/confirm port close-check
system/words/close port
]
write: func [
{Default write operation is a command, so check handshake.}
port "An open port spec"
data "Data to write"
/local here
][
port: port/sub-port
either here: find/match data "DATA" [
net-utils/confirm port data-check
insert port here
insert port "."
] [
net-utils/net-log data
insert port data
]
net-utils/confirm port write-check
]
read: func [
port "An open port spec"
data "A buffer to use for the read"
][
net-utils/net-log ["low level read of " port/state/num "bytes"]
read-io port/sub-port data port/state/num
]
get-sub-port: func [
port "An open port spec"
][
port/sub-port
]
awake: func [
prot "An open port spec"
][
none
]
get-modes: func [
port "An open port spec"
modes "A mode block"
][
system/words/get-modes port/sub-port modes
]
set-modes: func [
port "An open port spec"
modes "A mode block"
][
system/words/set-modes port/sub-port modes
]
data-check: ["DATA" "354"]
]
status: none
size: none
date: none
url: none
sub-port: none
locals: none
state: none
timeout: none
local-ip: none
local-service: none
remote-service: none
last-remote-service: none
direction: none
key: none
strength: none
algorithm: none
block-chaining: none
init-vector: none
padding: none
async-modes: none
remote-ip: none
local-port: none
remote-port: none
backlog: none
device: none
speed: none
data-bits: none
parity: none
stop-bits: none
rts-cts: true
user-data: none
awake: none
passive: none
cache-size: 5
]