Authenticated Email via ESMTP
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...
The set-net function has been expanded to add email user and password information. Use help to see their order:
>> help set-net USAGE: SET-NET settings DESCRIPTION: Network setup. All values after default are optional. Words OK for server names. SET-NET is a function value. ARGUMENTS: settings -- [email-addr default-server pop-server proxy-server p roxy-port-id proxy-type esmtp-user esmtp-pass] (Type: block)
set-net [email@example.com mail.example.com mail.example.com none none none "bob" "apple"] send firstname.lastname@example.org "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 email@example.com "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).
Updated 6-Jun-2023 - Copyright Carl Sassenrath - WWW.REBOL.COM - Edit - Blogger Source Code