[GB.NET.SMTP]

* NEW: The old SmtpClient class has been renamed to "_SmtpClass", so that 
  it is hidden.
* NEW: Add a gambas part to the component that implements the real 
  SmtpClass, by adding to _SmtpClass support for encryption (TLS or SSL).


git-svn-id: svn://localhost/gambas/trunk@2866 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2010-04-06 21:09:59 +00:00
parent a8c6cd99a3
commit 5ab6741683
7 changed files with 96 additions and 6 deletions

View file

@ -696,7 +696,7 @@ END_PROPERTY
GB_DESC CSmtpClientDesc[] =
{
GB_DECLARE("SmtpClient", sizeof(CSMTPCLIENT)),
GB_DECLARE("_SmtpClient", sizeof(CSMTPCLIENT)),
GB_METHOD("_new", NULL, SmtpClient_new, NULL),
GB_METHOD("_free", NULL, SmtpClient_free, NULL),
@ -723,11 +723,6 @@ GB_DESC CSmtpClientDesc[] =
GB_METHOD("Send", NULL, SmtpClient_send, NULL),
GB_CONSTANT("_IsControl", "b", TRUE),
GB_CONSTANT("_IsVirtual", "b", TRUE),
GB_CONSTANT("_Group", "s", "Network"),
GB_CONSTANT("_Properties", "s", "Host,Port,Debug"),
GB_END_DECLARE
};

View file

@ -0,0 +1,2 @@
[Desktop Entry]
Icon=./.icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,10 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r2851)
Title=gb.net.smtp
Startup=MMain
Version=0.0.7
Component=gb.net.smtp
TabSize=2
KeepDebugInfo=1
MakeComponent=1
State=1

View file

@ -0,0 +1,5 @@
' Gambas module file
Public Sub Main()
End

View file

@ -0,0 +1,7 @@
' Gambas class file
Export
Public Const None As Integer = 0
Public Const SSL As Integer = 1
Public Const TLS As Integer = 2

View file

@ -0,0 +1,71 @@
' Gambas class file
Export
Inherits _SmtpClient
Public Const _IsControl As Boolean = True
Public Const _IsVirtual As Boolean = True
Public Const _Group As String = "Network"
Public Const _Properties As String = "Host,Port,Debug,Encrypt{Net.None;SSL;TLS}"
Property Encrypt As Integer
Private $iCrypt As Integer
Private $hProcess As Process
Private Function Encrypt_Read() As Integer
Return $iCrypt
End
Private Sub Encrypt_Write(Value As Integer)
If Value = Net.None Or If Value = Net.TLS Or If Value = Net.SSL Then
$iCrypt = Value
Endif
End
Public Sub Send()
Dim bDefaultPort As Boolean
Dim sErr As String
bDefaultPort = Super.Port = 0
If $iCrypt = Net.SSL Then
If bDefaultPort Then Super.Port = 465
$hProcess = Exec ["openssl", "s_client", "-quiet", "-connect", Super.Host & ":" & Super.Port] For Read Write As "Process"
Super._NoGreeting = False
Super._Stream = $hProcess
Else If $iCrypt = Net.TLS Then
$hProcess = Exec ["openssl", "s_client", "-quiet", "-starttls", "smtp", "-connect", Super.Host & ":" & Super.Port] For Read Write As "Process"
Super._NoGreeting = True
Super._Stream = $hProcess
Else
Super._NoGreeting = False
Super._Stream = Null
Endif
Super.Send()
Finally
sErr = Error.Text
If $hProcess Then $hProcess.Kill
If bDefaultPort Then Super.Port = 0
Catch
Error.Raise(sErr)
End
Public Sub Process_Kill()
$hProcess = Null
End