I'm trying to send an email to someone using python and Nim. I want for the script to work with a DLL, so I compiled my Nim code into a DLL. When loading the DLL into python and calling a function from it, it displays this error:
out of memory
Process finished with exit code 1
The function call and DLL loading:
import ctypes
email_ = ctypes.CDLL("email_.dll", winmode=0)
message = email_.message
message.argtypes = [ctypes.c_wchar_p]
message.restype = None
message(
'Subj',
'msg',
'fromexample@gmail.com',
'frompassword',
'toexample@gmail.com'
)
And Nim DLL source code:
import smtp
import strutils
proc message*(
subject: string,
body: string,
mfrom: string,
password: string,
mto: string
) {.cdecl, exportc, dynlib.} =
var msg = smtp.createMessage(
subject,
body,
@[mto]
)
let smtpConn = newSmtp(useSsl=true, debug=true)
smtpConn.connect("smtp.gmail.com", Port(465))
smtpConn.auth(mfrom.split('@')[0], password)
smtpConn.sendMail(mfrom, @[mto], $msg)