Skip to content

Instantly share code, notes, and snippets.

@mcnemesis
Last active April 7, 2026 07:34
Show Gist options
  • Select an option

  • Save mcnemesis/a084d7a413226f430113662c33964bea to your computer and use it in GitHub Desktop.

Select an option

Save mcnemesis/a084d7a413226f430113662c33964bea to your computer and use it in GitHub Desktop.
TEA E-Mailer | a TEA app for sending emails
#/usr/bin/tttt -fc
#######################################
v:vABOUT:{@@@@@@| E-MAILER v1.7 |@@@@@@
Is a basic solution that enables you to readily send an email over the Internet without requiring any other sophisticated email clients. It just works anywhere TEA works. However, we basically help send the email on your behalf, in collaboration with Austrian AHASend... Since 2026}
#######################################
# Copyright 2026 Fut. Prof. JWL,
# Nuchwezi Research: Internet Services
#######################################
#---[CONSTANTS]
v:vEmailerFooter:{
@@@@@@[
Sent using TEA E-Mailer v1.7
]@@@@@@}
# first, store input user might have provided from outside this program
y*: | v:vExternalText
# basic menu/guide
v:vPROMPTBody:{Copy and Paste (or type-in: single-line) THE MESSAGE to be sent:}
v:vPROMPTSubject:{Copy and Paste (or type-in) THE SUBJECT for this email:}
v:vPROMPTTo:{Specify THE DESTINATION address for this email:}
v:vPROMPTFrom:{Specify THE ORIGIN/REPLY-to/CC address for this email:}
v:vDELIM:{
#-------------------
}
v:vPATTERN:{==_==}
v:vEMAIL_REGEX:{^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$}
v:vEMAILER_ADDRESS:{noreply@nuchwezi.com} # the actual sender
#---[VARIABLES]
v:vMailBody:{}
# initially, we want to use external input
# as default email-body/message
y:vExternalText|t!.:|v:vMailBody
l:lRESET
v:vMailSubject:{}
v:vMailFrom:{}
v:vMailTo:{}
v:vACTIntercept:0
#---[INTRODUCTIONS]
l:lINTRO
y:vABOUT|i*:
#---[BUILD E-MAIL PAYLOAD]
#check if we already have the email message, otherwise prompt..
l:lPROMPTBody
# test for body using cardinality [regex] test instead of regex on potentially problematic text..
y:vMailBody|t!.:|v:|y!:
f!:^0$:lHASBody
y:vPROMPTBody | i*: | t!.: | v:vMailBody
f:^$:lPROMPTBody:lHASBody
#we got the message
l:lHASBody
y:vMailBody | x*!:vEmailerFooter | v:vMailBody
# prompt for the subject..
l:lPROMPTSubject
y:vMailSubject|t!.:
f!:^$:lHASSubject
y:vPROMPTSubject | i*: | t!.: | v:vMailSubject
f:^$:lPROMPTSubject:lHASSubject
#we got the subject
l:lHASSubject
y:vMailSubject|t!.:|z*:|v:vMailSubject
# prompt for the destination..
l:lPROMPTTo
y:vMailTo|t!.:
f*:vEMAIL_REGEX:lHASTo
y:vPROMPTTo | i*: | t!.: | v:vMailTo
f*!:vEMAIL_REGEX:lPROMPTTo:lHASTo
#we got the destination address
l:lHASTo
y:vMailTo|t!.:|g:|v:vMailTo
# prompt for the origin/from/reply-to/cc..
l:lPROMPTFrom
y:vMailFrom|t!.:
f*:vEMAIL_REGEX:lHASFrom
y:vPROMPTFrom | i*: | t!.: | v:vMailFrom
f*!:vEMAIL_REGEX:lPROMPTFrom:lHASFrom
#we got the origin address
l:lHASFrom
y:vMailFrom|t!.:|g:|v:vMailFrom
# cross-check if the TO==FROM by error...
y:vMailFrom | x:{"}| x!:{"=="} | x*!:vMailTo | x!:{"}| r.:
f:true:lCONFIRM_SAME_ADDRESS:lADDRESS_DIFFERENT
l:lCONFIRM_SAME_ADDRESS
i!:{Looks like your FROM [} | x*!:vMailFrom | x!:{] and TO [} | x*!:vMailTo | x!:{] are The SAME!! If this is a mistake and you need to correct that, ENTER:
1. Go back and change addresses.
2. No, it's okay. Proceed. (default)
}
i: | t!.: | v:vOPT | f!:^1$:lADDRESS_DIFFERENT
# return to specify addresses...
v:vMailTo:{} | v:vMailFrom:{}
j:lPROMPTTo
l:lADDRESS_DIFFERENT
#---[PREVIEW E-MAIL PAYLOAD]
# we shall join the bits so that we see
# what it all looks like before we send it out
v:vS:{SUBJECT: }|v:vT:{TO: }|v:vF:{FROM: }|v:vNL:{
}|v:vPREAMBLE:{Before Sending, Please CONFIRM:}
v:vMENU_ACTION:{
=------[ CHOSE NEXT ACTION ]------=
1. EXIT/return payload
2. SEND/returns payload + sends out e-email
3. SEND+COMPOSE/sends e-mail + start next e-mail
4. COMPOSE/discard + restart..}
g*:{}:vS:vMailSubject:vDELIM:vT:vMailTo:vDELIM:vF:vMailFrom:vDELIM:vMailBody | v:vEMAILPreview
g*!:vNL:vMENU_ACTION:vDELIM:vPREAMBLE:vDELIM:vEMAILPreview | v:vPREVIEW_PROMPT
l:lPromptAction
# present what we have...
y:vPREVIEW_PROMPT| i*: | t!.: | v:vOPT
#---[PROCESS E-MAIL PAYLOAD]
#process what action user-chose...
y:vOPT | f!:^[1234]$:lPromptAction
f!:1:lNACT1
y:vEMAILPreview | q!:
l:lNACT1
y:vOPT | f!:2:lNACT2
l:lSENDEMAIL
# send out the email...
# first, prepare essential parameters...
v:vURL_MAILSERVICE:{https://utility.nuchwezi.com/sendemail}
v:Content-Type:{application/json}
# build a JSON payload...
i!:{{}
# NOTE: AHAsend requires that people not be allowed to impersonate
# arbitrary origin/from email addresses. Thus, we shall have to
# use ours as the sender --- until further notice!
#"from":{ "email":"hello@yourdomain.com"},
# BECAUSE of E-Mail Security, we shall offer
# to send on user's behalf - via our own address
x!:{"from":{ "email":"}| x*!:vEMAILER_ADDRESS| x!:{"},}
# or explicitly send as user-set from?
#x!:{"from":{ "email":"}| x*!:vMailFrom | x!:{"},}
# "to": [{"email": "user@example.com"}],
x!:{"to": [{"email": "}| x*!:vMailTo | x!:{"}],}
# As an Experimental feature, SENDER could be included in CC
# We might also configure explicit reply-to address??
# (exploring e-email routing options that is... )
x!:{"cc": [{"email": "}| x*!:vMailFrom | x!:{"}],}
x!:{"reply_to": {"email": "}| x*!:vMailFrom | x!:{"},}
# the rest of the parameters...
x!:{"subject":"}| x*!:vMailSubject | x!:{",}
x!:{"text_content":"}|
#we shall want to ensure we string-escape this value first..
v: #store current Payload in default vault
y:vMailBody | r!:{"}:{\"} | v:vMailBody_esc
# continue building payload...
y:
x*!:vMailBody_esc
| x!:{"} | x!:"}"
v:vJSON_EMAILPayload
# FIX: found that most JSON validators can't accept literal new-lines
r!:{
}:{\n}
v:vJSON_EMAILPayload
#q!: # inspect payload??
# set http headers...
w*.:Content-Type
# perform the http JSON data POST call...
w*@:vURL_MAILSERVICE:vJSON_EMAILPayload
#q!: # check what we got from api??
# return email payload and quit?
y:vACTIntercept | f:1:lNACT3
y:vEMAILPreview | q!:
l:lNACT2
y:vOPT | f!:3:lNACT3
v:vACTIntercept:1
# go to send logic...
j:lSENDEMAIL
l:lNACT3
# discard and restart e-mail composition...
v:vMailBody:{}
j:lRESET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment