Home   Archive   Permalink



eMail processing with Rebol R3 ?

Trying to find out if Rebol R3 can actually handle POP3 mail?
    
I've found a few examples of code snippets that pretend to be email handlers but they simply wont 'compile' under any Rebol R3 version !
    
At this stage I'd like some insight into how
Rebol R3 -- using the CLI if possible -- can allow me to display some email header info and prompt me to accept or delete the message from my ISP's mailbox.
    
I currently use a simple Ruby program for this task , but would really like to try Rebol R3.
Under Linux and or Android.
    
Its also confusing that all to often I find a R3 email 'lead' only to find the code is actually R2!


posted by:   dragoncity       5-Nov-2013/19:30:52-8:00



Graham has created some protocols for R3 that you can use for mail:
    
https://github.com/gchiu/Rebol3/tree/master/protocols

posted by:   Nick       6-Nov-2013/3:32:48-8:00



Thanks Nick,
    
I'd found these : prot-smtp.r3 , prot-send.r3 & also prot-mail.r3, but cannot
make them actually work.
    
From the little documentation enclosed in the code I knocked up the following, to send
a email to mself.
    
===========================================================
R E B O L [Title: test-mail.sr3 ]
    
do %prot-smtp.r
    
;; from prot-smtp.r comments
{ write smtp://user:password@smtp.yourisp.com compose [
                         from: me@somewhere.com
                         to: recipient@other.com
                         message: (message)
}
                        
write smtp://dragoncity:<passwordhere>@mail.isp.com.au compose [
                    from: dragoncity@isp.com.au
                    to: dragoncity@isp.com.au
                    message: { this is a test message from Rebol }
                     ]                
                                                        
halt
    
=============================================================
    
When run this happened :
    
>> do %test-mail.sr3
Script: test-mail.sr3 Version: none Date: none
Module: "Rebol 3 SMTP scheme" Version: 0.0.6 Date: 9-Jan-2010 20-Jan-2013
port opened ...
=== Client event: lookup
=== Client event: connect
connected
=== Client event: read
S: 220 poplet4.per.eftel.com ESMTP Postfix
    
C: EHLO Rebol3 User PC
    
=== Client event: wrote
=== Client event: read
S: 250-poplet4.per.eftel.com
250-PIPELINING
250-SIZE 15360000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
                             <<<<< quite along time delay here
>>
                             <<<<< checking my email , no message appears, nor rejected
                                     message.

posted by:   dragoncity       6-Nov-2013/7:50:27-8:00



Notice in the comments of prot-smtp.r:
    
"Where message is an email with all the appropriate headers.
    
In Rebol2, this was constructed by the 'send function"
    
Graham provides this example:
    
message: rejoin [ {To: } recipient@other.com {
From: } "R3 User" { <} me@somewhere.com {>
Date: Mon, 21 Jan 2013 17:45:07 +1300
Subject: testing from r3
X-REBOL: REBOL3 Alpha
    
where's my kibble?}]

posted by:   Nick       6-Nov-2013/9:24:50-8:00



Thanks for your info, Nick. I had noticed that "message:" item ,
but as I'd already entered that information into the
"write smtp....." code I was confused as to why I'd need to reenter it again. :-)
    
I set up a "message:" item as shown in the %prot-smtp.r and tried again, %do test-mail.sr3,
with the same result, same messages, a long delay ( about 1 minute ) and
then .. nothing...
    
Not making much progress I'm afraid.
    
An observation: I hard coded the date-time info into message:,
does Rebol include a function to create that date-time format directly from the system?


posted by:   dragoncity       7-Nov-2013/0:21:22-8:00



Have you tried messaging Graham in AltME? He's active there.
    
R2 has a "to-idate" function, which depends on the to-itime function. Since both are mezzanine, you can copy them directly into R3 scripts:
    
to-itime: func [
     {Returns a standard internet time string (two digits for each segment)}
     time [time! number! block! none!]
     /local pad
][
     time: make time! time
     pad: func [n] [head insert/dup n: form n #"0" 2 - length? n]
     rejoin [
         pad time/hour ":" pad time/minute ":"
         pad round/down time/second
     ]
]
to-idate: func [
     "Returns a standard Internet date string."
     date [date!]
     /local str
][
     str: form date/zone
     remove find str ":"
     if (first str) <> #"-" [insert str #"+"]
     if (length? str) <= 4 [insert next str #"0"]
     reform [
         pick ["Mon," "Tue," "Wed," "Thu," "Fri," "Sat," "Sun,"] date/weekday
         date/day
         pick ["Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"] date/month
         date/year
         to-itime any [date/time 0:00]
         str
     ]
]
    
probe to-idate now
halt


posted by:   Nick       7-Nov-2013/14:04:21-8:00



Notice that both those functions are found in the prot-send.r script (you can get them by typing "source to-idate" and "source to-itime" in R2)

posted by:   Nick       7-Nov-2013/17:35:24-8:00



Thanks Nick,
I've made my own module by cut&paste the code above.
    
Will try to get in touch with Graham via AltME.
    


posted by:   dragoncity       7-Nov-2013/21:13:36-8:00



Hi guys
    
Use the prot-send.r which needs prot-smtp.r
    
so,
    
first setup your user specific passwords etc in https://github.com/gchiu/Rebol3/blob/master/protocols/prot-send.r#L25
    
Then
    
do %prot-smtp.r
do %prot-send.r
    
then the use is as in R2
    
send someone@rebol.com "my message"
    
Looks like there is a later version of prot-smtp.r at https://gist.github.com/gchiu/5288312
    
I also have a prot-pop3.r somewhere ... not sure why I didn't put it up on github yet.

posted by:   Graham       8-Nov-2013/2:17:42-8:00



As for what you want to do which is review your messages and delete based on viewing the first few lines, perhaps that is best suited to IMAP. I did write a prot-imap some years ago too https://github.com/gchiu/Rebol3/blob/master/protocols/prot-imap.r but untested since then.
    
Otherwise you're looking at a TOP command for POP3.

posted by:   Graham       8-Nov-2013/2:24:51-8:00




R E B O L [Title: "test-mail.sr3" ]
    
do %prot-smtp.r
do %prot-send.r
    
isp: "mail.aanet.com.au"
    
idate: to-idate now
prin "** internet date :" print idate
    
user: make object! [
         name: "brett" ; string!
         email: dragoncity@aanet.com.au ; email!
         smtp: isp ; ip address or name
         pop3: isp ; ip address or name
         user: "XXXXXXXXXX" ; or esmtp-user
         pass: "PPPPPPPPPP" ; or esmtp-pass
]
    
print user
print "** call Send"
send XXXXXXXXX@aanet.com.au "test message"
    
print now                                                    
halt
    
    
===========================================================
>> do %test-send.sr3
Script: "test-mail.sr3" Version: none Date: none
Module: "Rebol 3 SMTP scheme" Version: 0.0.8 Date: 9-Jan-2010 20-Jan-2013 29-Mar-2013
Script: "REBOL Protocols: Send Email" Version: 2.7.6 Date: 14-Mar-2008 21-Jan-2013
** internet date :Fri, 8 Nov 2013 20:44:51 +1100
name: "brett"
email: XXXXXXXXXX@aanet.com.au
smtp: "mail.aanet.com.au"
pop3: "mail.aanet.com.au"
user: "XXXXXXXXXX"             <---- suppressed
pass: "PPPPPPPPPP"
** call Send
port opened ...
=== Client event: lookup
client state: INIT
=== Client event: connect
client state: INIT
connected
=== Client event: read
client state: EHLO
S: 220 poplet4.per.eftel.com ESMTP Postfix
    
code: 220
code-group: 2
C: EHLO rebol3 user pc
    
=== Client event: wrote
client state: AUTH
=== Client event: read
client state: AUTH
S: 250-poplet4.per.eftel.com
250-PIPELINING
250-SIZE 15360000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
    
code: 250
code-group: 2
determining authentication methods
                                     <----- long wait here
8-Nov-2013/20:45:51+11:00
>>


posted by:   dragoncity       8-Nov-2013/5:13:45-8:00



That's very odd, your smtp server does not seem to be responding to the AUTH command. The server should respond with the type of authentication methods supported so that the Rebol client can pick one and then authenticate. What happens when you use Rebol2?

posted by:   Graham       8-Nov-2013/13:09:54-8:00



Prot-smtp is actually an esmtp server ie. it expects to authenticate. Looking again at your exchange above, your server doesn't seem to support authentication. So, I would have to remove that part that looks for 250-AUTH from the protocol

posted by:   Graham       8-Nov-2013/13:37:16-8:00



Graham,
You are correct about authentication !
    
Looking at my Email Configuration ( I use CLAWS ),
authentication is OFF, also I checked my original ISP setup guide and :
    
"If you are receiving Authentication errors double check that you have
no SSL or special authentication
settings checked in your mail client configuration"
    
I will check their current recommendations, but as my other mail accessing
programs function, I guess its unchanged from original install in 2008,
    
Brett


posted by:   dragoncity       8-Nov-2013/19:55:12-8:00



Graham, for your info.
    
I currently use POP3 to receive mail, and SMTP to send. I don't know if that's "normal" or not !
Brett

posted by:   dragoncity       8-Nov-2013/20:20:51-8:00