* contrib/hbtip/ccgi.prg
* contrib/hbtip/client.prg
* contrib/hbtip/encb64.prg
* contrib/hbtip/encoder.prg
* contrib/hbtip/encqp.prg
* contrib/hbtip/encurl.prg
* contrib/hbtip/ftpcli.prg
* contrib/hbtip/hbtip.hbp
* contrib/hbtip/hbtip.hbx
* contrib/hbtip/httpcli.prg
* contrib/hbtip/log.prg
* contrib/hbtip/mail.prg
* contrib/hbtip/mime.c
* contrib/hbtip/misc.c
* contrib/hbtip/popcli.prg
* contrib/hbtip/sessid.prg
* contrib/hbtip/smtpcli.prg
* contrib/hbtip/thtml.ch
* contrib/hbtip/thtml.prg
* contrib/hbtip/tip.ch
* contrib/hbtip/url.prg
+ contrib/hbtip/base64u.prg
+ contrib/hbtip/mailassy.prg
* contrib/hbtip/sendmail.prg -> [...]/mailsend.prg
+ contrib/hbtip/WARNING.txt
* contrib/hbtip/tests/base64.prg
* contrib/hbtip/tests/dbtohtml.prg
* contrib/hbtip/tests/dnldftp.prg -> [...]/ftp_dl.prg
* contrib/hbtip/tests/ftpadv.prg -> [...]/ftp_adv.prg
+ contrib/hbtip/tests/email.prg
+ contrib/hbtip/tests/ftp_ul.prg
- contrib/hbtip/tests/gmail.hbp
- contrib/hbtip/tests/gmail.prg
* contrib/hbtip/tests/hbmk.hbm
* contrib/hbtip/tests/httpadv.prg -> [...]/http_adv.prg
* contrib/hbtip/tests/httpcli.prg -> [...]/http_cli.prg
+ contrib/hbtip/tests/http_qry.prg
- contrib/hbtip/tests/loadhtml.prg
+ contrib/hbtip/tests/test.prg
+ contrib/hbtip/tests/url.prg
* synced with 3.4 fork by Viktor Szakats
; the only difference is slightly edited WARNING.txt
- contrib/hbtip/credent.prg
% deleted TIPCredentials() class that was never implemented
; changes above come from vast number of commits in 3.4 repository - many
thanks to Viktor Szakats for maintaining
100 lines
2.8 KiB
Plaintext
100 lines
2.8 KiB
Plaintext
/* TIP Mail - reading and writing multipart mails
|
|
*
|
|
* Creating a mail message.
|
|
* This will create a valid mail message, using
|
|
* the set of files given in the command-line.
|
|
*/
|
|
|
|
#require "hbtip"
|
|
|
|
PROCEDURE Main( ... )
|
|
|
|
LOCAL oMail, cData, i, oAttach
|
|
LOCAL cFname
|
|
|
|
IF PCount() == 0
|
|
Usage()
|
|
RETURN
|
|
ENDIF
|
|
|
|
oMail := TIPMail():New( "This is the body of the mail" )
|
|
oMail:hHeaders[ "Content-Type" ] := "text/plain; charset=utf-8"
|
|
oMail:hHeaders[ "Date" ] := tip_TimeStamp()
|
|
|
|
FOR i := 1 TO PCount()
|
|
|
|
SWITCH Lower( cData := hb_PValue( i ) )
|
|
CASE "-h"
|
|
Usage()
|
|
RETURN
|
|
CASE "-f"
|
|
IF HB_ISSTRING( cData := hb_PValue( ++i ) )
|
|
oMail:hHeaders[ "From" ] := hb_StrToUTF8( cData )
|
|
ENDIF
|
|
EXIT
|
|
CASE "-t"
|
|
IF HB_ISSTRING( cData := hb_PValue( ++i ) )
|
|
oMail:hHeaders[ "To" ] := hb_StrToUTF8( cData )
|
|
ENDIF
|
|
EXIT
|
|
CASE "-s"
|
|
IF HB_ISSTRING( cData := hb_PValue( ++i ) )
|
|
oMail:hHeaders[ "Subject" ] := hb_StrToUTF8( cData )
|
|
ENDIF
|
|
EXIT
|
|
CASE "-b"
|
|
IF HB_ISSTRING( cData := hb_PValue( ++i ) )
|
|
oMail:SetBody( hb_StrToUTF8( cData ) + e"\r\n" )
|
|
ENDIF
|
|
EXIT
|
|
CASE "-m"
|
|
IF HB_ISSTRING( cData := hb_PValue( ++i ) )
|
|
IF ( cData := hb_MemoRead( cData ) ) == ""
|
|
? "Fatal: Could not read", hb_PValue( i )
|
|
RETURN
|
|
ENDIF
|
|
oMail:SetBody( cData + e"\r\n" )
|
|
ENDIF
|
|
EXIT
|
|
OTHERWISE // it is an attachment file
|
|
IF ( cData := hb_MemoRead( cData ) ) == ""
|
|
? "Fatal: Could not read attachment or attachment empty", hb_PValue( i )
|
|
RETURN
|
|
ENDIF
|
|
|
|
oAttach := TIPMail():New()
|
|
oAttach:SetEncoder( "base64" )
|
|
// TODO: mime type magic auto-finder
|
|
cFName := hb_FNameNameExt( hb_PValue( i ) )
|
|
// Some EMAIL readers use Content-Type to check for filename
|
|
oAttach:hHeaders[ "Content-Type" ] := ;
|
|
"application/X-TIP-Attachment; filename=" + cFName
|
|
// But usually, original filename is set here
|
|
oAttach:hHeaders[ "Content-Disposition" ] := ;
|
|
"attachment; filename=" + cFname
|
|
oAttach:SetBody( cData )
|
|
|
|
oMail:Attach( oAttach )
|
|
ENDSWITCH
|
|
NEXT
|
|
|
|
/* Writing stream */
|
|
OutStd( oMail:ToString() )
|
|
|
|
RETURN
|
|
|
|
STATIC PROCEDURE Usage()
|
|
|
|
? "Usage:"
|
|
? " tipmmail [options] attachment1, attachment2..."
|
|
? "Options:"
|
|
? " -h Help"
|
|
? ' -f "from" Set "mail from" field'
|
|
? ' -t "to" Set "mail to" field'
|
|
? ' -s "subject" Set mail subject'
|
|
? ' -b "body" Set mail body (or message)'
|
|
? ' -m "bodyfile" Set mail body using a file'
|
|
?
|
|
|
|
RETURN
|