Email Demo: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "::'''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''' {{CodeStart}} c = {{Cl|_OPENCLIENT}}("tcp/ip:25:YOUR ISP SMTP SERVER ADDRESS") IF c = 0 THEN PRINT "Couldn't connect to SMTP server!": SYSTEM crlf$ = {{Cl|CHR$}}(13) + {{Cl|CHR$}}(10) ' carriage return + line feed {{Cl|ASCII}} characters a$ = "HELO localhost" + crlf$ {{Cl|PUT (TCP/IP statement)|PUT #}...")
 
No edit summary
 
Line 46: Line 46:




''See also:''
{{PageSeeAlso}}
 
* [[_OPENCLIENT]], [[_OPENHOST]]
* [[_OPENCLIENT]], [[_OPENHOST]]
* [[_OPENCONNECTION]], [[_CONNECTED]]
* [[_OPENCONNECTION]], [[_CONNECTED]]

Latest revision as of 00:33, 29 January 2023

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



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link