Script

Show Script

Showing code for: includes/mail.irev

Back

<?rev

-- mail scripts thanks to splash21: <http://forums.on-rev.com/viewtopic.php?f=3&t=171>

-- 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


-- wrap quotes around text
function q pText
        return quote & pText & quote
end q


-- send an email
command mail pTo, pSub, pMsg, pFrom
        put shellEscape(pTo) into pTo
        put shellEscape(pSub) into pSub
        put shellEscape(pMsg) into pMsg
        put shellEscape(pFrom) into pFrom
        get shell("echo -e" && q(pMsg) && "| mail -s" & q(pSub) && q(pTo) && "-- -f" & q(pFrom))
end mail