Send e-mails (+/- files attached) with Purebasic as simply as possible.
Features :
- authentication supported [ POP3 before SMTP / SMTP LOGIN ]
- large attachements
Note : TLS/SSL is not supported
Works well! One little thing. I was a little confused for a while by trying to compare #PureSMTP_Ok with the return value of PureSMTP_OpenSMTPConnection() which always didn't match. I then tested PureSMTP_OpenSMTPConnection() return value on a good connection and found it to be 100 and not 1. Not a big deal but maybe useful to mention it in the doc. Good job though, it even recognises ascii files and encodes them 7bit instead of just base64'ing the lot! 8O Nice!
Thanks.
You are right : #PureSMTP_Ok is only valid for PureSMTP_SendMail().
PureSMTP_OpenSMTPConnection() returns 0 if failed ; if <> 0 it's Ok.
Maybe I change this if there is a next version.
But... some e.mail functions must be added (like send HTML or LOGIN in erver).
Do you think to extend them?
Joaquin
HTML : perhaps I would if I knew how it works but I must say I never looked. My goal was not to build an e-mail client, but to provide a simple way to send some messages / files with Purebasic.
;===========================================================================
;-USAGE
;===========================================================================
;
; syntax:
; Blat <filename> -To <recipient> [optional switches (see below)]
; Blat -install <server addr> <sender's addr> [<try>[<port>[<profile>]]] [-q]
; Blat -profile [-delete | "<default>"] [profile1] [profileN] [-q]
; Blat -h [-q]
;
; -install <server addr> <sender's addr> [<try n times> [<port> [<profile>]]]
; : set's SMTP server, sender, number of tries and port for profile
; (<try n times> And <port> may be replaced by '-').
;
; <filename> : file with the message body ('-' For console input, End with ^Z)
; -To <recipient> : recipient list (also -t) (comma separated)
; -tf <recipient> : recipient list filename
; -subject <subj>: subject Line (also -s)
; -f <sender> : overrides the Default sender address (must be known To server)
; -i <addr> : a 'From:' address, not necessarily known To the SMTP server.
; -cc <recipient>: carbon copy recipient list (also -c) (comma separated)
; -cf <file> : cc recipient list filename
; -bcc <recipient>: blind carbon copy recipient list (also -bcc) (comma separated)
; -bf <file> : bcc recipient list filename
; -organization <organization>: Organization field (also -o And -org)
; -body <text> : Message body
; -x <X-Header: detail>: Custom 'X-' header. eg: -x "X-INFO: Blat is Great!"
; -r : Request Return receipt.
; -d : Request disposition notification.
; -h : displays this help.
; -q : supresses *all* output.
; -Debug : Echoes server communications To screen (disables '-q').
; -noh : prevent X-Mailer header from showing homepage of blat
; -noh2 : prevent X-Mailer header entirely
; -p <profile> : send with SMTP server, user And port defined in <profile>.
; -priority <pr> : set message priority 0 For low, 1 For high.
; -server <addr> : Specify SMTP server To be used. (optionally, addr:port)
; -port <port> : port To be used on the server, defaults To SMTP (25)
; -hostname <hst>: Select the hostname used To send the message
; -mime : MIME Quoted-Printable Content-Transfer-Encoding.
; -enriched : Send an enriched text message (Content-Type=text/enriched)
; -html : Send an HTML message (Content-Type=text/html)
; -uuencode : Send (binary) file UUEncoded
; -base64 : Send (binary) file using base64 (binary Mime)
; -try <n times> : how many time blat should try To send. from '1' To 'INFINITE'
; -attach <file> : attach binary file To message (may be repeated)
; -attacht <file>: attach text file To message (may be repeated)
; -ti <n> : Set timeout To 'n' seconds.
; -u <username> : Username For AUTH LOGIN (use with -pw)
; -pw <password> : Password For AUTH LOGIN (use with -u)
; -log <filename>: Log everything but usage To <filname>
; -plain : Use AUTH PLAIN To login To SMTP server (use with -u -pw)
; -charset <cs> : User defined charset. The Default is ISO-8859-1
;
; Note that If the '-i' option is used, <sender> is included in 'Reply-to:'
; And 'Sender:' fields in the header of the message.
;
; Optionally, the following options can be used instead of the -f And -i
; options:
;
; -mailfrom <addr> The RFC 821 MAIL From: statement
; -from <addr> The RFC 822 From: statement
; -replyto <addr> The RFC 822 Reply-To: statement
; -returnpath <addr> The RFC 822 Return-Path: statement
; -sender <addr> The RFC 822 Sender: statement
;
; For backward consistency, the -f And -i options have precedence over these
; RFC 822 defined options. If both -f And -i options are omitted then the
; RFC 821 MAIL FROM statement will be defaulted To use the installation-defined
; Default sender address
;
; EXAMPLES:
;
; Blat -install smtphost.bar.com foo@bar.com // Sets host And userid
; Blat -install smtphost.bar.com foo // Sets host And userid
; Blat -install smtphost.bar.com // Sets host only
;
; Blat myfile.txt -subject "A file for pedro" -To foo@bar.com
; // Sends a file with subject line "A file for pedro"
;
; Blat myfile.txt -subject "A file for pedro" -To foo@bar.com -q
; // Sends a file with subject line "A file for pedro" And does not print
; // informative messages on the console
;
; Blat myfile.txt -subject "A file for mark" -To fee@fi.com -f foo@bar.com
; // -f option overrides the Default sender
;
; Blat myfile.txt -subject "A file for pedro" -To foo@bar.com -i "devil@fire.hell"
; // -i replaces "From:" line address (but leaves Reply-To: And Sender: lines)
;
; Blat myfile.txt -subject "animals" -To fee@fi.com -cc "moo@grass.edu,horse@meadow.hill"
; // -c mails carbon copies To users moo@grass.edu And horse@meadow.hill
;
; Blat.exe BLAT.ZIP -subject "file to gil" -To foo@bar.com -base64
; // Sends the binary file BLAT.ZIP To Gilles in MIME Base 64 format
;
; Blat.exe BLAT.ZIP -subject "file to gil" -To foo@bar.com -uuencode
; // Sends the binary file BLAT.ZIP To Gilles in the old UUEncode format
;
; Blat myfile.txt -subject "oumpla" -To foo@bar.com -attach c:\myfolder\*.txt
; // Sends a file with subject line "oumpla", attach all files with extension "TXT"
; // in folder "myfolder" on drive "C:". Note: you must specify a filename/pattern,
; // "-attach .\*.*" will send all files in current folder.
; // "-attach ." will not send anything And WILL NOT GIVE YOU ANY WARNING.
;
; Blat myfile.txt -To fee@fi.com -server smtp.domain.com -port 6000
; // sends the message through SMTP server smtp.domain.com at port 6000
;
; Blat myfile.txt -To fee@fi.com -hostname friend
; // tells the SMTP that this computer is called "friend"
;
; The DLL works in exactly the same way as Blat.exe !
Changes :
- added PureSMTP_GetLastServerMessage() function : get last SMTP server message (usefull after #PureSMTP_BadResponse)
- all functions return the same codes (#PureSMTP_Ok etc...)
- bug fix
About username/password authentication :
I don't have any example. What should I do : send USER, wait for '+OK', send PASS, wait for '+OK', and then continue the SMTP stuff (HELO etc...) ?
gnozal wrote:Library update (see first post of thread)
About username/password authentication :
I don't have any example. What should I do : send USER, wait for '+OK', send PASS, wait for '+OK', and then continue the SMTP stuff (HELO etc...) ?
(from a google search) however i have not met a SMTP server requiring it though most smtp server restrict access from your ip/sender email or
require you to login in theri pop3 acount before ...
even thought both MozillaMail /Outlook supports it
Library updated 18 oct 2004 (see first post of thread)
Changes :
- added function PureSMTP_OpenPOP3ThenSMTPConnection(POP3Server.s, POP3Port.l, POP3UserName.s, POP3UserPassword.s, SMTPServer.s, SMTPPort.l)
Open connection to POP3 server (authentification) and then to SMTP server
I could not test it, so tell me if it works !