Commit 644bac2ac5b560415aa631a148fe5c055d63d200

Thomas de Grivel 2025-01-07T14:19:28

smtp: sendmail

diff --git a/.ikc3_history b/.ikc3_history
index be56dfe..efcb53e 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,4 +1,3 @@
-1/3 * 2
 1/3 * 2 * 3
 (Integer) (1/3 * 2 * 3)
 type((Integer) (1/3 * 2 * 3))
@@ -97,3 +96,4 @@ false || false
 false || 0
 true && 1
 true && 10
+SMTP.sendmail("dx@kmx.io", "Thomas de Grivel", "root@kmx.io", "Charlie Root", "test", "Test test !")
diff --git a/lib/kc3/0.1/smtp.kc3 b/lib/kc3/0.1/smtp.kc3
index 713ed32..0300620 100644
--- a/lib/kc3/0.1/smtp.kc3
+++ b/lib/kc3/0.1/smtp.kc3
@@ -10,7 +10,20 @@ defmodule SMTP do
   # header_add(smtp, header_name, value)
   def header_add = cfn Bool "kc3_smtp_header_add" (Ptr, Str, Str)
 
+  # mail(smtp, body) => success
+  def mail = cfn Bool "kc3_smtp_mail" (Ptr, Str)
+
   # open(server, port, security, flags, cafile, dest)
   def open = cfn Ptr "kc3_smtp_open" (Str, Str, Sym, Sym, Str, Result)
 
+  def sendmail = fn (from, from_name, to, to_name, subject, body) {
+    if smtp = open("localhost", "25", :none, :none, "") do
+      true = address_add(smtp, :from, from, from_name)
+      true = address_add(smtp, :to, to, to_name)
+      true = header_add(smtp, "Subject", subject)
+      true = mail(smtp, body)
+      true = close(smtp)
+    end
+  }
+
 end
diff --git a/smtp b/smtp
index e913e2f..1caff75 160000
--- a/smtp
+++ b/smtp
@@ -1 +1 @@
-Subproject commit e913e2f01fdc594b83ce0bbe01dd5ff71b419b8f
+Subproject commit 1caff75f7b79ac30fc125e44583d2cfd102936fb