QB64 Phoenix Edition
Email Demo (from 6/6/2014) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: Email Demo (from 6/6/2014) (/showthread.php?tid=2161)



Email Demo (from 6/6/2014) - SMcNeill - 11-13-2023

Code: (Select All)
c = _OPENCLIENT("tcp/ip:25:YOUR ISP SMTP SERVER ADDRESS")
IF c = 0 THEN PRINT "Couldn't connect to SMTP server!": SYSTEM

crlf$ = CHR$(13) + CHR$(10) ' carriage return + line feed ASCII characters

a$ = "HELO localhost" + crlf$
PUT #c, , a$: SLEEP 2
GET #c, , b$: PRINT b$; ' send command, wait & print server reply

a$ = "MAIL FROM:<anonymous@verizon.net>" + crlf$
PUT #c, , a$: SLEEP 2: GET #c, , b$: PRINT b$; ' send command, wait & print server reply

a$ = "RCPT TO:<galleondragon@gmail.com>" + crlf$
PUT #c, , a$: SLEEP 2: GET #c, , b$: PRINT b$; ' send command, wait & print server reply

a$ = "DATA" + crlf$
PUT #c, , a$: SLEEP 2: GET #c, , b$: PRINT b$; ' send command, wait & print server reply

a$ = "" ' assemble communication string
a$ = a$ + "From: Paul <anonymous@verizon.net>" + crlf$ ' your email address
a$ = a$ + "To: Galleon <galleondragon@gmail.com>" + crlf$ ' send email to address
a$ = a$ + "Subject: My first QB64 email" + crlf$
a$ = a$ + crlf$ ' space
a$ = a$ + "Please reply to let me know if this works!" + crlf$ ' message
a$ = a$ + "Thanks for developing QB64!" + crlf$
a$ = a$ + "." + crlf$
PUT #c, , a$: SLEEP 2
GET #c, , b$: PRINT b$; ' send message, wait & print server reply

a$ = "QUIT" + crlf$
PUT #c, , a$: SLEEP 2: GET #c, , b$: PRINT b$; ' end message, wait & print server reply

CLOSE c

PRINT "Send Email request complete."
END

IMPORTANT: YOU MUST CHANGE the _OPENCLIENT statement TO YOUR ISP'S SMTP SERVER ADDRESS