根据gen_smtp提供的方法试过多次,总是不对。
今天看了一下ChicagoBoss的实现方法。 终于发送出去了。
1> MailOptions=[{relay,"163.com"},
1> {auth,never},
1> {tls,if_available},
1> {ssl,false},
1> {hostname,"localhost"},
1> {retries,1}].
[{relay,"163.com"},
{auth,never},
{tls,if_available},
{ssl,false},
{hostname,"localhost"},
{retries,1}]
"\r\n","From",": ",
"Subject",": ","sdfsdf","\r\n",
"Date: ",
"Wed, 11 Apr 2012 17:34:05 +0800",
"\r\n","Content-Type: ",
"text/plain","\r\n",
"MIME-Version: ","1.0","\r\n",
"Message-ID: ",
[60,
[["32"],
["a7"],
["a3"],
["57"],
["15"],
["c9"],
["b9"],
["b7"],
["c1"],
["db"],
["7f"],
["27"],
["67"],
["8f"],
["a2"],
["d2"]],
64,"localhost",62],
"\r\n"].
"\r\n","Date: ","Wed, 11 Apr 2012 17:34:05 +0800","\r\n",
"Content-Type: ","text/plain","\r\n","MIME-Version: ","1.0",
"\r\n","Message-ID: ",
[60,[["32"],["a7"],[[...]],[...]|...],64,"localhost",62],
"\r\n"]
6>
6> Body="test body"
6> .
"test body"
7> F= fun() -> [MessageHeader, "\r\n", Body] end
7> .
#Fun<erl_eval.20.21881191>
#Fun<erl_eval.20.21881191>}
13> gen_smtp_client:send(Email, MailOptions).
{ok,<0.53.0>}
14>
17> A=F()
17> .
"\r\n","Date: ","Wed, 11 Apr 2012 17:34:05 +0800","\r\n",
"Content-Type: ","text/plain","\r\n","MIME-Version: ","1.0",
"\r\n","Message-ID: ",
[60,[["32"],[[...]],[...]|...],64,"localhost",62],
"\r\n"],
"\r\n","test body"]
19> F1=F().
"\r\n","Date: ","Wed, 11 Apr 2012 17:34:05 +0800","\r\n",
"Content-Type: ","text/plain","\r\n","MIME-Version: ","1.0",
"\r\n","Message-ID: ",
[60,[["32"],[[...]],[...]|...],64,"localhost",62],
"\r\n"],
"\r\n","test body"]
20> F1}.
"\r\n","Date: ","Wed, 11 Apr 2012 17:34:05 +0800","\r\n",
"Content-Type: ","text/plain","\r\n","MIME-Version: ","1.0",
"\r\n","Message-ID: ",
[60,[...]|...],
"\r\n"],
"\r\n","test body"]}
21> gen_smtp_client:send(Email1, MailOptions).
{ok,<0.65.0>}
以前测试不通 就是格式没写对。