32 lines
1.2 KiB
Text
32 lines
1.2 KiB
Text
begin_instruct(Send email)_param({str} from, to, cc, subject, msg, {html}, htmlmsg)_opt({cred}, login)_ns(rosettacode);
|
|
set_thread(linger);
|
|
find_thing()_first()_email()
|
|
? with_found()_label(emailer);
|
|
: exit_instruct[]_err(Sorry, no one can send emails!);
|
|
;
|
|
with_[emailer]_format(html)
|
|
? with_[emailer]_cred[login]_email[htmlmsg]_from[from]_to[to]_cc[cc]_subject[subject];
|
|
: exit_instruct[]_err(Something went wrong with the email);
|
|
: with_[emailer]_cred[login]_email[msg]_from[from]_to[to]_cc[cc]_subject[subject];
|
|
: exit_instruct[]_err(Something went wrong with the email);
|
|
;
|
|
reset_thread();
|
|
end_instruct[];
|
|
|
|
set_namespace(rosettacode);
|
|
|
|
// Set up credentials
|
|
add_var({cred}, mycred)_server(esvr1)_username(bob)_password(p@$$w0rd); // Other credentials can be added here
|
|
|
|
// Send email:
|
|
exec_instruct(Send email)_param()
|
|
_from(bob@bobmail.com.invalid) // It is at the discretion of the caller to use this from address
|
|
_to(fred@bobmail.com.invalid)
|
|
_cc(jill@bobmail.com.invalid)
|
|
_subject(Rosettacode wants me to send an email!)
|
|
_msg(This is the body of my email.)
|
|
_htmlmsg(<b>This is the body of my email, in bold</b>)
|
|
_login[mycred]
|
|
_me();
|
|
|
|
reset_namespace();
|