[EMAIL PROTECTED] wrote:

> Hi Rebols !
>
> I'm brand new to this language/philosophy but it looks real promising.
> I'm definetly going to learn this...
> I've got a concrete exercise that I want to solve using rebol so that I can
> learn quicker.
> I guess I'm hoping somebody will help a beginner get off to a flying start.
>
> So here goes ...
>
> I have mail going to a specific user called "email" that contains a header
> field called "reference:"
> This "reference" field contains the email address of the intended recipient.
> I'd like to read this field, parse the email address and resend the email
> to this new address (including the message body of course).
> The message should then be deleted from "emails" mailbox.
>
> I need to check the "email" mailbox (say every 5 minutes) to see if any new
> messages have arrived and forward them to the "real" intended recipient.
>
> Here is an example mailbox file belonging to "email"
>

forever [

     email: open pop://email:[EMAIL PROTECTED]

          while [not tail? email][
                         msg: import-email first email
                         resend first msg/reference [EMAIL PROTECTED] first
email
                         email: next email
           ]

    close email
    wait 00:05

]


I am not sure however, how import-email function will parse your header. By
default, it stores to, from, reply-to adresses into block, so - if it is gonna
be string, use "resend to-email msg/reference [EMAIL PROTECTED] first email" in
above code ...

Note: completly untested, just a quick hack before I go to bet - simple and
easy, isn't it? :-) Well, that's REBOL! :-)

-pekr-

>
> <----Mailbox------ START ---->
>
> >From [EMAIL PROTECTED]  Wed May 31 16:25:54 2000
> Return-Path: <[EMAIL PROTECTED]>
> Delivered-To: [EMAIL PROTECTED]
> Received: from mailer1.mydomain.com
>  by mailf.mydomain.com (Postfix) with SMTP id BC2B11FA0A
>  for <[EMAIL PROTECTED]>; Wed, 31 May 2000 16:25:54 +0200 (CEST)
> Received: from mailer1.mydomain.com with TCP; Wed, 31 May 2000 16:19:43
> +0000
> Date:  Wed, 31 May 2000 16:19:43 +0000
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject:  Testmail 1
> Reference:  [EMAIL PROTECTED]
> Message-Id: <[EMAIL PROTECTED]>
>
> Body Text for email 1.
>
> >From [EMAIL PROTECTED]  Wed May 31 16:26:28 2000
> Return-Path: <[EMAIL PROTECTED]>
> Delivered-To: [EMAIL PROTECTED]
> Received: from mailer1.mydomain.com with TCP; Wed, 31 May 2000 16:20:17
> +0000
> Date:  Wed, 31 May 2000 16:20:17 +0000
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject:  testmail 2
> Reference:  [EMAIL PROTECTED]
> Message-Id: <[EMAIL PROTECTED]>
>
> Body Text for email 2.
>
>   <----Mailbox------ END ---->
>
> I realise this is probably trivial - REBOL can obviously do powerful things
> with a few lines of code.
> I've read the manuals and looked at the library examples regarding mail but
> can't
> seem to get started properly (sigh .. so much to learn, so fast ...)
>
> regards
>
> Simon

Reply via email to