为什么用JAVA发送邮件,只有标题,没有正文?(100分请教)
socket = new Socket(smtp.getText(), 25);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
send(null);
send("HELO "+java.net.InetAddress.getLocalHost().getHostName());
send("AUTH LOGIN");
send(Base64.encode("n71929688"));
send(Base64.encode("12071208"));
send("MAIL From:"+from.getText());
send("RCPT To:"+to.getText());
send("DATA");
String a = "\r\n.\r\n";
out.println("Content-Type: text/plain;charset="+"GB2312");
out.println("adslfjlasjdfalsdfj");
out.flush();
send(a);
public void send(String msg) throws
IOException {
if(msg!=null)
{
out.println(msg);
out.flush();
}
String line = in.readLine();
if(line != null)
state.setText(state.getText()+line+"\n");
}
这是相关代码
------解决方案--------------------强烈关注...
------解决方案--------------------
呵呵! 邮件协议规定,最前面的是header,里面是subject,datetime等内容,
然后以一个空行标志主体内容的开始
然后才是.结束,比如
subject:121212121212
body
.
你的那个只输出了header部分,你应该再看看协议