Darwin cgi engine and sendmail
Sivakatirswami
katir at hindu.org
Sun Oct 30 01:13:28 EDT 2005
Here you go Dave.. .from the application here that generates our
Daily Hindu Press international..
This is running from a rev desktop stack in the GUI, but I'm pretty
sure it will work from a CGI...
One caveat there is a conf variable set for security, which limits
the length of a single line input to sendmail to 990 chars. (google
"sendmail 990" for this obscure bit of info) Longer strings are auto
broken with CRLF as far as I can tell. There are all kinds of scary
admonitions not to change this setting (old mail client issues) hence
my dreaful work around in the switch statement below.
Of course this assume the email is properly formatted I haven't
included that here.. if you need it I can post that too... in the
following "tMsg" contains a properly formatted, multi-part html/plain
text email...
# fix endlines to unix a
replace numTochar(13) with numTochar (10) in tMsg
# temp back up to hard drive
put ($HOME &"/Desktop/temp.txt") into tPath
put tMsg into url ("binfile:" & tPath)
# introduce line breaks at the end of sentences into lines
longer that 990 chars
# and two such breaks in the case of lines longer than 1980 chars.
# will break lines up to 2970 chars.
# Lines longer than that (very unlikely) will be broken by Sendmail
at 990 with CRLF
# which appears as a space in the html email and a line break and
space in the plain
# text version. This eliminates both:
repeat for each line tLine in tMsg
switch
case len(tLine)<990
put tLine & cr after tWrappedMsg
next repeat
break
Case len(tLine)>1980
set the itemdel to "."
put round(the number of items of tLine/3) into tBreakPoint
put cr before item (tBreakPoint+1) of tLine
put cr before item (tBreakPoint*2) of tLine
put tLine & cr after tWrappedMsg
next repeat
break
Case len(tLine)>990
set the itemdel to "."
put round(the number of items of tLine/2) into tBreakPoint
put cr before item (tBreakPoint+1) of tLine
put tLine & cr after tWrappedMsg
next repeat
break
end switch
end repeat
set the itemdel to "," # just in case!
put tWrappedMsg into tMsg
replace cr with "\n" in tMsg #probably not needed if everything
is running from CGI...
put tMsg into $DailyHPIEmail
# Do shell stuff and send mail, very simple...
set the shellcommand to "/bin/sh"
put "echo -e $DailyHPIEmail | sendmail -f hpi.list at hindu.org " &
(fld "to" of cd "staticText") into tCmd
# check on status and inform user
put shell(tCmd) into tResult
if tResult is empty then
answer "Mail was sent...." with "OK"
else
answer tResult with "OK"
end if
end createFinalEmailAndSendIt
On Oct 28, 2005, at 11:33 AM, Dave Cragg wrote:
> Hi good people
>
> Does anyone have any experience of using sendmail from the Darwin
> cgi engine? (OS X 10.4.2)
>
> If so, could you let me know how it's done? Or if you know it's not
> possible, could put me out of my misery and let me know.
>
> Cheers
> Dave
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list