[On-Rev] sending email thru sendmail?!

Jeffrey Massung massung at gmail.com
Wed Mar 3 09:56:02 EST 2010


I can't remember where I found this code, but I've been using it quite successfully with On-Rev:

-- escape shell characters: use this function before passing data to the shell
function shellEscape pText
        repeat for each char tChar in "\`$" & quote
                replace tChar with "\" & tChar in pText
        end repeat
        return pText
end shellEscape

-- send an email message to someone
command sendMail pFrom, pTo, pSub, pBody
	-- fix each of the parameters of the email
	put shellEscape(pFrom) into pFrom
	put shellEscape(pTo) into pTo
	put shellEscape(pSub) into pSub
	put shellEscape(pBody) into pBody

	-- send the mail using the shell command
	get shell("echo -e" && quote & pBody & quote && "| mail -s" & quote & pSub & quote && quote & pTo & quote && "-- -f" & quote & pFrom & quote)
end sendMail

HTH,

Jeff M.

On Mar 3, 2010, at 7:55 AM, Andre Garzia wrote:

> Aloha Folks,
> 
> Did anyone here is able to send email using sendmail in On-Rev, my code that
> I use everywhere is not working anymore, somehow it can't open the sendmail
> process.
> 
> function sendMail pFrom, pTo, pSubject, pBody
> 
>  switch the platform
>  case "Linux"
>    put "/usr/sbin/sendmail -t" into mprocess
>    open process mprocess for write
>    write "From:" && pFrom & crlf to process mprocess
>    write "To:" &&   pTo  &  crlf to process mprocess
>    write "Subject:" &&  pSubject  &  crlf & crlf to process mprocess
>    write   pBody &  crlf to process mprocess
>    close process mprocess
>    wait until mprocess is not among the lines of the openprocesses
>    return the result
>    break
> 
>  end switch
> 
> end sendMail
> 
> -- 
> http://www.andregarzia.com All We Do Is Code.
> _______________________________________________
> 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