Email Demo
Jump to navigation
Jump to search
- IMPORTANT: This is a QB64 only program that requires the TCP/IP upgrade.
- YOU MUST CHANGE the _OPENCLIENT statement TO YOUR ISP'S SMTP SERVER ADDRESS
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 |
' Notes:' Your SMTP address is something like "mail.myisp.com" or "outgoing.verizon.net". Crlf ASCII characters 13 + 10 signal the end of a message or command line. Some IP servers may block your outgoing email if they suspect that messages are SPAM! The block may be for a few hours! Keep that in mind when using this demo.
See also: