Re: STARTTLS - send secure email 4D v15.5

2018-07-02 Thread Bruno LEGAY via 4D_Tech
Hi,

Generally (convention) smtp on port 25 is unencrypted.

C_LONGINT($vl_error;$vl_ssl;$vl_port;$vl_protocol)

$vl_port:=25
$vl_protocol:=2  //2 = SMTP or SMTP with STARTTLS
$vl_error:=IT_SetPort ($vl_protocol;$vl_port)

$vl_ssl:=0   // sessionParam Longint 0 or omitted = Do not use SSL but 
switchover allowed
$vl_error:=SMTP_Send ($vl_smtpId;$vl_ssl)

NOTE : if the SMTP server supports the option STARTTLS, the connexion will 
switch to  SSL/TLS secured connexion (see below). Otherwise the connexion is 
not secured.



SMTP on port 465 is explicit ssl. ie. The tcp connexion starts with a SSL/TLS 
handshake.

C_LONGINT($vl_error;$vl_ssl;$vl_protocol;$vl_port;$vl_protocol)

$vl_port:=465
$vl_protocol:=12  //12 = SMTP SSL
$vl_error:=IT_SetPort ($vl_protocol;$vl_port)

$vl_ssl:=1   // sessionParam Longint 0 or omitted = Do not use SSL but 
switchover allowed
$vl_error:=SMTP_Send ($vl_smtpId;$vl_ssl)


With SMTP on port 587, the connexion starts unencrypted. If the SMTP server 
replies that it can support option STARTTLS (on port 587 it should), then the 
tcp connexion switches from unencrypted to SSL/TLS secured connexion (SSL/TLS 
handshake), and then the login/password are exchanged. 
This is automatic and transparent (since 4D v13.2).


C_LONGINT($vl_error;$vl_ssl;$vl_port;$vl_protocol)

$vl_port:=587
$vl_protocol:=2  //2 = SMTP or SMTP with STARTTLS
$vl_error:=IT_SetPort ($vl_protocol;$vl_port)

$vl_ssl:=0   // sessionParam Longint 0 or omitted = Do not use SSL but 
switchover allowed
$vl_error:=SMTP_Send ($vl_smtpId;$vl_ssl)


Note that the SSL/TLS handshake on an open unencrypted tcp connexion (switching 
a connexion from unencrypted to secured) is impossible to do with 4D IC tcp 
commands (or NTK AFAIK)...


HTH
Bruno
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: STARTTLS - send secure email 4D v15.5

2018-07-02 Thread jarosz via 4D_Tech
Hello Keisuke


Thank you for your clarification. You imply that the only way to request a
secure TLS connection is by using "0" and hope that the server requests a
switch to SSL.

How is it possible to tell that the email was sent securely?

Is it possible to ensure that the email is ONLY sent if the connection is
secure?
And not sent if a secure connection is not available.

Thanks

Michael




--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: STARTTLS - send secure email 4D v15.5

2018-06-30 Thread Keisuke Miyako via 4D_Tech
keep in mind that the effect of "1" (use SSL) has been adjusted over the years.

in v12.1, when SSL was first introduced, it simply meant "SMTP over SSL" a.k.a. 
implicit SSL.

this is the kind SSL that is considered "less secure", for example by Google,
where the user must explicitly turn on "access for less secure apps".

v13.2 extended the "use SSL" option,
where 0 (previously "don't use SSL") is now STARTTLS, a.k.a. explicit SSL.
the plugin will automatically switch to SSL when requested by the server.

"1" (SMTP over SSL) is kept for compatibility.
the plugin will NOT switch to SSL in response to the STARTTLS command.

2018/06/29 16:53、jarosz via 4D_Tech 
<4d_tech@lists.4d.com> のメール:
$error:=SMTP_Send ($smtp_id;1)  // to force use of ssl?
It's when I do this that I get the timeout error and no send.



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: STARTTLS - send secure email 4D v15.5

2018-06-29 Thread jarosz via 4D_Tech
Hello Mike

Many thanks for your code.

I wonder, have you ever used it with:

$error:=SMTP_Send ($smtp_id;1)  // to force use of ssl?

It's when I do this that I get the timeout error and no send.

Michael Jarosz




--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: STARTTLS - send secure email 4D v15.5

2018-06-27 Thread Michael McCall via 4D_Tech
Not sure if this helps at all but in case it does, this works for us running 4D 
v16 R5. We use it to connect to our Exchange account using the Office 365 
hosting service.

// long working version
C_LONGINT($error;$sslSMTPPort)
C_LONGINT($smtp_id)
C_TEXT($smtpHost)
C_TEXT($replyTo;$sendEmailTo)
C_TEXT($msg;$subject)

$sslSMTPPort:=587  // port used for SSL SMTP - gmail wants 465
$smtpHost:="smtp.office365.com"  
$User:="u...@companyname.com"  
$Pass:="YourPassword"  
$replyTo:="u...@companyname.com"  // have replies sent here

$sendEmailTo:="recipi...@companyname.com"
$BCCsendEmailTo:="recipi...@companyname.com "
$subject:="This is a test at "+String(Current time)
$msg:="Hello world out there."

$error:=IT_SetPort (2;$sslSMTPPort)  //12 is for 'SMTP with SSL'

$error:=SMTP_New ($smtp_id)
$error:=SMTP_Host ($smtp_id;$smtpHost;0)
$error:=SMTP_Auth ($smtp_id;$User;$Pass;0)
SMTP_AddHeader ($smtp_id;"Importance";"Normal";0)
$error:=SMTP_From ($smtp_id;$User;1)
$error:=SMTP_ReplyTo ($smtp_id;$User;0)
$error:=SMTP_To ($smtp_id;$sendEmailTo;0)
$error:=SMTP_Bcc ($smtp_id;$BCCsendEmailTo;0)
$error:=SMTP_Subject ($smtp_id;$subject;0)
$error:=SMTP_Body ($smtp_id;$msg;0)
$error:=SMTP_Send ($smtp_id;0)  //1 to use ssl

Mike McCall

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**