Files
harbour-core/contrib/hbtip/tests/email.prg
Viktor Szakats 1938dd0a70 2017-04-14 13:22 UTC+0200 Aleksander Czajczynski (hb fki.pl)
* 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
2017-04-14 13:22:09 +02:00

92 lines
2.7 KiB
Plaintext

/* Copyright 2009 Viktor Szakats (vszakats.net/harbour) */
#require "hbssl"
#require "hbtip"
#if ! defined( __HBSCRIPT__HBSHELL )
REQUEST __HBEXTERN__HBSSL__
#endif
#include "simpleio.ch"
PROCEDURE Main( cFrom, cPassword, cTo, cHost )
LOCAL nPort
LOCAL lSTARTTLS := .F.
IF ! tip_SSL()
? "Error: Requires SSL support"
RETURN
ENDIF
hb_default( @cFrom , "<from@example.net>" )
hb_default( @cPassword, "password" )
hb_default( @cTo , "to@example.com" )
hb_default( @cHost , "localhost" )
cHost := Lower( cHost )
/* SMTPS works with SSL/TLS on port 465 and with STARTTLS
on port 587. STARTTLS mode is fully automatic and requires
SSL/TLS be disabled at first (it will be activated on
request after STARTTLS command) */
DO CASE
CASE cHost == "apple" .OR. "@icloud.com" $ cFrom .OR. "@mac.com" $ cFrom .OR. "@me.com" $ cFrom
cHost := "smtp.mail.me.com"; lSTARTTLS := .T.
CASE cHost == "fastmail" .OR. "@fastmail.com" $ cFrom .OR. "@fastmail.fm" $ cFrom
cHost := "smtp.fastmail.com"
CASE cHost == "gmx.net" .OR. "@gmx.net" $ cFrom .OR. "@gmx.ch" $ cFrom .OR. "@gmx.de" $ cFrom
cHost := "mail.gmx.net"; lSTARTTLS := .T.
CASE cHost == "google" .OR. "@gmail.com" $ cFrom .OR. "@googlemail.com" $ cFrom
cHost := "smtp.gmail.com"
CASE cHost == "mail.ru" .OR. "@mail.ru" $ cFrom
cHost := "smtp.mail.ru"
CASE cHost == "netease" .OR. "@163.com" $ cFrom
cHost := "smtp.163.com"
CASE cHost == "office365"
cHost := "smtp.office365.com"; lSTARTTLS := .T.
CASE cHost == "outlook" .OR. "@outlook.com" $ cFrom .OR. "@hotmail.com" $ cFrom
cHost := "smtp-mail.outlook.com"; lSTARTTLS := .T.
CASE cHost == "sina" .OR. "@sina.com" $ cFrom
cHost := "smtp.vip.sina.com"
CASE cHost == "uol" .OR. "@uol.com.br" $ cFrom
cHost := "smtps.uol.com.br"
CASE cHost == "yahoo" .OR. "@yahoo.com" $ cFrom
cHost := "smtp.mail.yahoo.com"
CASE ":" $ cHost
IF TUrl():New( cHost ):nPort != -1
nPort := TUrl():New( cHost ):nPort
ENDIF
lSTARTTLS := ( nPort == 587 )
cHost := TUrl():New( cHost ):cServer
ENDCASE
hb_default( @nPort, iif( lSTARTTLS, 587, 465 ) )
? "Host:", cHost, hb_ntos( nPort ), iif( lSTARTTLS, "(STARTTLS)", "" )
? tip_MailSend( ;
cHost, ;
nPort, ;
cFrom, ;
cTo, ;
NIL /* CC */, ;
{} /* BCC */, ;
"test: body", ;
"test: subject", ;
NIL /* attachment */, ;
cFrom, ;
cPassword, ;
"", ;
NIL /* nPriority */, ;
NIL /* lRead */, ;
.T. /* lTrace */, ;
.F., ;
NIL /* lNoAuth */, ;
NIL /* nTimeOut */, ;
NIL /* cReplyTo */, ;
nPort == 465 )
RETURN