我在 ubuntu 10.10 工作,我使用 Erlang。
我的目标是编写代码以便从 Erlang 发送邮件。
这是我的代码:
-module(mailer).
-compile(export_all).
send(Destination, Subject, Body) ->
D = string:join(lists:map( fun(Addr) -> binary_to_list(Addr) end, Destination ), " " ),
S = io_lib:format("~p",[binary_to_list(Subject)]),
B = io_lib:format("~p",[binary_to_list(Body)]),
os:cmd("echo "" ++ B ++ "" | mail -s "" ++ S ++ "" " ++ D).
并执行我尝试的发送功能:
Erlang R13B03 (erts-5.7.4) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.4 (abort with ^G)
1> mailer:send([<<"testFrom@mail.com">>, <<"testto@yahoo.fr">>], <<"hello">>, <<"Hello guys">>..
"/bin/sh: mail: not found\n"
如您所见,我有此错误:
/bin/sh: mail: not found