diff --git a/gb.net.smtp/src/CSmtpClient.c b/gb.net.smtp/src/CSmtpClient.c index 2c22c7a95..8f2345287 100644 --- a/gb.net.smtp/src/CSmtpClient.c +++ b/gb.net.smtp/src/CSmtpClient.c @@ -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 }; diff --git a/gb.net.smtp/src/gb.net.smtp/.directory b/gb.net.smtp/src/gb.net.smtp/.directory new file mode 100644 index 000000000..06dab1c8a --- /dev/null +++ b/gb.net.smtp/src/gb.net.smtp/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/gb.net.smtp/src/gb.net.smtp/.icon.png b/gb.net.smtp/src/gb.net.smtp/.icon.png new file mode 100644 index 000000000..2d5b29f56 Binary files /dev/null and b/gb.net.smtp/src/gb.net.smtp/.icon.png differ diff --git a/gb.net.smtp/src/gb.net.smtp/.project b/gb.net.smtp/src/gb.net.smtp/.project new file mode 100644 index 000000000..e6dc4338e --- /dev/null +++ b/gb.net.smtp/src/gb.net.smtp/.project @@ -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 diff --git a/gb.net.smtp/src/gb.net.smtp/.src/MMain.module b/gb.net.smtp/src/gb.net.smtp/.src/MMain.module new file mode 100644 index 000000000..c21a66e7b --- /dev/null +++ b/gb.net.smtp/src/gb.net.smtp/.src/MMain.module @@ -0,0 +1,5 @@ +' Gambas module file + +Public Sub Main() + +End diff --git a/gb.net.smtp/src/gb.net.smtp/.src/Net.class b/gb.net.smtp/src/gb.net.smtp/.src/Net.class new file mode 100644 index 000000000..89e79b34e --- /dev/null +++ b/gb.net.smtp/src/gb.net.smtp/.src/Net.class @@ -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 diff --git a/gb.net.smtp/src/gb.net.smtp/.src/SmtpClient.class b/gb.net.smtp/src/gb.net.smtp/.src/SmtpClient.class new file mode 100644 index 000000000..94f0b00ec --- /dev/null +++ b/gb.net.smtp/src/gb.net.smtp/.src/SmtpClient.class @@ -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