gmailrebolrebol2

Send email via GMail SMTP in REBOL 2


I am new to REBOL. People blogging about how great REBOL is used sending an email as an example, similar to this example from the "send" documentation:

send luke@rebol.com "Testing REBOL Function Summary"

having read how easy and convenient it is to do this, I excitedly tried to send myself a test email via my GMail account.

I looked at the official GMail help for SMTP/POP to get the relevant SMTP/POP server names: https://support.google.com/mail/answer/7104828?hl=en

And here is how far the "send" and "set-net" documentation got me:

>> set-net [ myrealusername@gmail.com smtp.gmail.com pop.gmail.com ]
>> send myrealusername@gmail.com "Hello me!"
connecting to: smtp.gmail.com
** Access Error: Cannot connect to smtp.gmail.com
** Where: open-proto
** Near: smtp-port: open [scheme: 'esmtp]
either only

On reflection, of course it didn't work; I told REBOL nothing about wanting to use SSL/TLS, the relevant port numbers, or my GMail password. It must need all of the above to actually send an email.

So how do I do it?


Solution

  • I modified the protocols some years ago to work with gmail. I hope that they still work.

    You'll need to run both the prot-ssmtp.r and prot-ssend.r, and you'll need a version of rebol2 which supports ssl. This is either a free view build, or a paid core build.

    do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssmtp.r
    do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssend.r
    

    Now, you can either set the user and password manually:

    system/schemes/esmtp/user: "username"
    system/schemes/esmtp/pass: "password"
    

    or, when the script runs the very first time, you will be asked the values so that they can be set for that rebol instance. The prot-ssmtp uses port 465 but you can modify that if it's no longer correct.

    And then it should be as straight forward after setting set-net as:

    ssend email@someon.com "This is my message"
    

    Note that we now have email on ren-c which is the open source fork of rebol3.