REBOL Technologies

Authenticated Email via ESMTP

Carl Sassenrath, CTO
REBOL Technologies
24-Jun-2005 22:27 GMT

Article #0180
Main page || Index || Prior Article [0179] || Next Article [0181] || Post Comments || Send feedback

REBOL/View 1.3 and Core 2.6 support sending authenticated email via the ESMTP protocol. It's easy to use, but you must be careful too. Here are a few notes to get you started...

Using Set-Net

The set-net function has been expanded to add email user and password information. Use help to see their order:

>> help set-net
    SET-NET settings

     Network setup.  All values after default are optional.  Words OK
 for server names.
     SET-NET is a function value.

     settings -- [email-addr default-server pop-server proxy-server p
    roxy-port-id proxy-type esmtp-user esmtp-pass] (Type: block)

For example:

set-net [ none
    none none "bob" "apple"]
send "This is a message"


If you do not provide a user and password, REBOL is programmed to prompt you for user and password when you send email to a server that requires authentication.

In the Protocol Object

If you print the source code to set-net, you can see what it is actually doing. Near the end of the code, you will see is how to set the user and password for the ESMTP protocol. You can do that directly with code such as:

system/schemes/esmtp/user: "bob"
system/schemes/esmtp/pass: "apple"

send "This is a message"

Warning About Your Password

If you run scripts that require your ESMTP email password, make sure that they are never stored in a disk file as plain text or as a REBOL string. It is better to prompt for the password with code such as:

set [user pass] request-pass
if not user [quit]  ; exit if not provided

If you must store passwords into files, then you should at least encrypt them. A simple encryption method is provide on all REBOL distributions and advanced encryption methods are provided in REBOL/SDK products.

The encloak function provides simple encryption. It is advised that you use a good encryption key and longer passwords (because the result of encloak is always the same length as its source string).

Post Comments

Updated 4-Mar-2024   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code