阅读更多 use org.apache.commons.net.smtp.AuthenticatingSMTPClient

private void sendLogByEmail(){
String sender = "mxy200@163.com";
String recipient = "mxy200@126.com";
String sendMsg = getData();
if(sendMsg == null)
return;
try {
AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
//client.addProtocolCommandListener(new PrintCommandListener(
                //new PrintWriter(System.out), true));
client.connect("smtp.163.com");
int reply = client.getReplyCode();
if(!SMTPReply.isPositiveCompletion(reply)) {
client.disconnect();
return;
}
client.elogin();
client.auth(AuthenticatingSMTPClient.AUTH_METHOD.LOGIN, sender,"20142924");
client.setSender(sender);
            client.addRecipient(recipient);
            SimpleSMTPHeader header = new SimpleSMTPHeader(sender, recipient, "vlook log,"+CacheService.User_Id);            
           
            Writer writer = client.sendMessageData();
            if (writer != null)
            {
                writer.write(header.toString());
               
                writer.write("\n"+SkinDef.CLIENT_IDENTIFIER+","+SkinDef.APP_SUB+","+Config.BUILD_VER);
                writer.write(" net="+NetManager.getTelNetWrokType());
                if(NetManager.mNetType == Define.NET_PROXY)
                writer.write("\nproxy net,host:"+NetManager.mProxyHost+",port:"+NetManager.mProxyPort);
               
                writer.write(sendMsg);
                writer.close();
                client.completePendingCommand();
            }
           
client.logout();
client.disconnect();
}
catch (Exception e) {
e.printStackTrace();
}
}

更多相关文章

  1. android 连接CMWAP
  2. Android再按一次退出程序实现方法
  3. android 客户端 smtp 协议发送数据
  4. Android(安卓)打开pdf文档,没有阅读器链接到Google Play Store等
  5. Android源码在线阅读
  6. android : 圆角按钮 shape属性
  7. OpenGL ES教程V之更多3D模型(原文对照)
  8. Android(安卓)TextView 给文本中指定片段添加自定义点击事件
  9. android : 圆角按钮 shape属性

随机推荐

  1. golang数组和切片的区别是什么
  2. golang用什么ide
  3. golang中协程和线程的区别是什么?
  4. golang编程语言能开发啥
  5. golang数据类型有哪些
  6. golang数组与切片的区别是什么?
  7. golang语言可以做些什么
  8. golang如何判断数据类型
  9. golang是什么语言?
  10. golang语言的出现解决了什么问题