LC server, tsNetSmtpSync, mimeEncode and ignorance

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, 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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: LC server, tsNetSmtpSync, mimeEncode and ignorance

Post by bangkok » Tue Apr 13, 2021 5:14 am

I had the same question, with HostM (hosting company with LC Server).

Here is the answer, and it works flawlessly.

First you need to copy onto the server, the "mime.livecodescript" file, that you'll find in

/Extension/com.livecode.library.mime/ directory (on your PC)

Then in the lc file :

Code: Select all

tsNetInit
put $_SERVER["PATH_TRANSLATED"] into tScriptFolder
set the itemDel to "/"
delete item -1 of tScriptFolder
set the itemDel to ","
start using (tScriptFolder & "/mime.livecodescript")

Post Reply

Return to “CGIs and the Server”