Send email: Difference between revisions
Content added Content deleted
m (Lingo added) |
|||
Line 764: | Line 764: | ||
</lang> |
</lang> |
||
=={{header|Lingo}}== |
|||
Lingo has no built-in support for sending email. But this can be achieved e.g. by using Shell Xtra and one of the available command-line SMTP clients. |
|||
{{libheader|Shell Xtra}} |
|||
<lang lingo> |
|||
---------------------------------------- |
|||
-- Sends email via SMTP using senditquiet.exe (15 KB) |
|||
-- @param {string} fromAddr |
|||
-- @param {string} toAddr - multiple addresses separated with ; |
|||
-- @param {string} subject |
|||
-- @param {string} message - use "\n" for line breaks |
|||
-- @param {string} [cc=VOID] - optional; multiple addresses separated with ; |
|||
-- @param {string} [bcc=VOID] - optional; multiple addresses separated with ; |
|||
-- @param {propList} [serverProps=VOID] - allows to overwrite default settings |
|||
-- @return {bool} success |
|||
---------------------------------------- |
|||
on sendEmail (fromAddr, toAddr, subject, message, cc, bcc, serverProps) |
|||
sx = xtra("Shell").new() |
|||
-- senditquiet.exe in folder "bin" relative to current movie |
|||
sx.shell_setcurrentdir(_movie.path&"bin") |
|||
-- defaults |
|||
host = "smtp.gmail.com" |
|||
protocol = "ssl" |
|||
port = 587 |
|||
user = "johndoe" |
|||
pass = "foobar" |
|||
-- if propList 'serverProps' was passed, overwrite defaults |
|||
if ilk(serverProps)=#propList then |
|||
repeat with i = 1 to serverProps.count |
|||
do(serverProps.getPropAt(i)&"=""E&serverProps[i]"E) |
|||
end repeat |
|||
end if |
|||
cmd = "senditquiet" |
|||
put " -s "&host after cmd |
|||
put " -protocol "&protocol after cmd |
|||
put " -port "&port after cmd |
|||
put " -u "&user after cmd |
|||
put " -p "&pass after cmd |
|||
put " -f ""E&fromAddr"E after cmd |
|||
put " -t ""E&toAddr"E after cmd |
|||
put " -subject ""E&subject"E after cmd |
|||
put " -body ""E&message"E after cmd |
|||
-- optional args |
|||
if not voidP(cc) then put " -cc ""E&cc"E after cmd |
|||
if not voidP(bcc) then put " -bcc ""E&bcc"E after cmd |
|||
put "1>nul 2>nul&if errorlevel 1 echo ERROR" after cmd |
|||
res = sx.shell_cmd(cmd) |
|||
return not(res contains "ERROR") |
|||
end</lang> |
|||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |