I was looking for a way to better define email recipients along the lines of the To/CC/BCC convention. Although SYSTEM/STANDARD/EMAIL contains CC and BCC fields, they are not currently functional, see:How to Add Addresses to the BCC Field Using Rebol's Send FunctionTherefore in this solution, I've reorganised the SEND command to do my bidding based in part on this handy little answer:Sending BCC emails using an SMTP Server (by @eml)The SEND FunctionThe key is collecting ALL recipient addresses from To/CC/BCC (and the ADDRESS function argument) for use with the SMTP RCPT command, then reformatting the To/CC fields and setting BCC to none before composing the header object. Preliminary tests seem to indicate this approach works.(Also included here is the function uses SYSTEM/STANDARD/EMAIL as a base for the header object, so you only need pass a block/minimal object as an argumentthis should preserve the 'copy part of the message for the subject line' feature)send: func [    {Send a message to an address (or block of addresses)}     address [email! block!] An address or block of addresses     message Text of message. First line is subject.     /only Send only one message to multiple addresses     /header Supply your own custom header     header-obj [block! object!] The header to use     /attach Attach file, files, or [.. [filename data]]     files [file! block!] The files to attach to the message     /subject Set the subject of the message     subj The subject line     /show Show all recipients in the TO field     /local smtp-port boundary make-boundary tmp from][    make-boundary: does []    if file? files [files: reduce [files]]     message: either string? message [copy message] [mold message]    ; bases any custom object on SYSTEM/STANDARD/EMAIL    header-obj: make system/standard/email any [        header-obj        [subject: any [subj copy/part message any [find message newline 50]]]    ]    if subject [header-obj/subject: subj]    either none? from: any [        header-obj/from        header-obj/from: system/user/email    ][        net-error Email header not set: no from address    ][        if all [            string? system/user/name            not empty? system/user/name        ][            header-obj/from: rejoin [system/user/name  < from >]        ]    ]     address: collect [        foreach recipient compose [(address)][            if email? recipient [keep recipient]        ]    ]    if find [email! block!] type?/word header-obj/to [        append address header-obj/to: collect [            foreach recipient compose [(header-obj/to)][                if email? recipient [keep recipient]            ]        ]    ]    header-obj/to: unless empty? address [        rejoin remove collect [            foreach recipient address: unique address [                keep ,                 keep recipient            ]        ]    ]    header-obj/cc: if find [email! block!] type?/word header-obj/cc [        append address header-obj/cc: unique collect [            foreach recipient compose [(header-obj/cc)][                if email? recipient [keep recipient]            ]        ]        unless empty? header-obj/cc [            rejoin remove collect [                foreach recipient unique header-obj/cc [                    keep ,                     keep recipient                ]            ]        ]    ]    ; notes on BCC here: https://stackoverflow.com/a/26611044/292969    if find [email! block!] type?/word header-obj/bcc [        append address collect [            foreach recipient compose [(header-obj/bcc)][                if email? recipient [keep recipient]            ]        ]    ]    header-obj/bcc: none    if empty? address: unique address [        net-error No recipients specified.    ]    if none? header-obj/date [        header-obj/date: to-idate now    ]    if attach [        boundary: rejoin [--__REBOL-- system/product -- system/version -- checksum form now/precise __]        header-obj/MIME-Version: 1.0        header-obj/content-type: join multipart/mixed; boundary= [{} skip boundary 2 {}]        message: build-attach-body message files boundary    ]    smtp-port: open [scheme: 'esmtp]    ; The use of BCC makes it so SHOW is somewhat redundant. Possibly ONLY too.    ; either only [        ; address: copy address        ; remove-each value address [not email? :value]    message: head insert insert tail net-utils/export header-obj newline message    insert smtp-port reduce [from address message]        ; probe reduce [from address message]    ; ][    ;   foreach addr address [    ;       if email? addr [    ;           if not show [insert clear header-obj/to addr]    ;           tmp: head insert insert tail net-utils/export header-obj newline message    ;           insert smtp-port reduce [from reduce [addr] tmp]    ;       ]    ;   ]    ; ]    close smtp-port]TestingTesting requires credentials to access an ESMTP server per the first lines below:; originator credentialssystem/user/name: Foo Bertsystem/user/email: foo@bar.comsystem/schemes/default/host: mail.serversystem/schemes/esmtp/user: mail.server.usersystem/schemes/esmtp/pass: mail.server.passsystem/standard/email/content-type: text/plain; trace/net onsend/header bar@foo.com Message Content [    To: bar@foo.com ; redundant, but here for completeness    CC: baz@foo.com    BCC: baz@bar.com    Subject: A Test Email]Replace addresses as necessary!ReviewI'm looking to ascertain if:The function works as advertisedWhether this is the right approach (seems to be a more efficient use of an SMTP instance)I am overlooking any other design considerationsAs a bonus, this would make the /ONLY and /SHOW refinements redundant
Alteration of Rebol's SEND favouring To/CC/BCC fields for defining recipients
email;rebol;rebol2