LC server, tsNetSmtpSync, mimeEncode and ignorance

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
LeProfBard
Posts: 17
Joined: Thu Mar 26, 2020 8:23 pm

LC server, tsNetSmtpSync, mimeEncode and ignorance

Post by LeProfBard » Fri Apr 10, 2020 5:55 pm

Hi,
I'm trying to send an email via SMTP on the LC hosting server via a simple .lc script. The script is below, but the server chokes on the "mimeEncode..." command: it doesn't know what to do with it. What am I missing?

<?lc

put "[correct username]" into tSettings["username"]
put "[correctPW]" into tSettings["password"]

put "This Should be my content" into tBody
put "[oneEmailAddress]" into tSender
put "[AnotherEmailAddress]" into tRecipient
put "Should be my subject line" into tSubject

put "[correctServerAndPortNumber]" into tUrl

mimeEncodeAsMIMEEmail tBody, "[oneEmailAddress]", "[AnotherEmailAddress]", , "My Subject Line"

tsNetInit
put tsNetSmtpSync(tURL, tSender, tRecipient, it, tResponseHeaders, tBytes, tSettings) into tResult

if the first word of tResult is "tsneterr:" then
put "Error" && tResult
else
put "E-mail sent"
end if

?>

LeProfBard
Posts: 17
Joined: Thu Mar 26, 2020 8:23 pm

Re: LC server, tsNetSmtpSync, mimeEncode and ignorance

Post by LeProfBard » Tue Apr 14, 2020 6:48 pm

Hi,
If anyone is interested, here is the helpful response I got from the LC team--and it works!
So it turns out that the problem with "MimeEncodeAsMimeEmail" is that it's not present by default in LiveCode Server. You need to add the MIME library to the server and start using it... so if you add the line:

start using "...mime[.]livecodescript"

to your script then "MimeEncodeAsMimeEmail" will work from LiveCode Server (this should handle other MIME functions as well).
I placed the 'start using' script just above the call to "MimeEncodeAsMimeEmail" and it worked perfectly!
Le PB

Post Reply

Return to “CGIs and the Server”