public void send(View view){
//密码验证器
Authenticator pass_info=new Authenticator(){
@Override
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("用户名", "密码");
}
};
//服务器信息
Properties properties = new Properties();
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.host", "smtp.163.com");
properties.put("mail.smtp.port", "25");
Session session=Session.getDefaultInstance(properties,pass_info);
try{
message=new MimeMessage(session);
message.setFrom(new InternetAddress("xxx@163.com"));//发件地址
message.setRecipient(Message.RecipientType.TO,new InternetAddress("xxx@163.com"));//收件地址
message.setSubject("[hi]");//主题
message.setSentDate(new Date());//发送时间
message.setText(messagE.getText().toString());//设置内容
new Thread(){
@Override
public void run()
{
try
{
Transport.send(message);
}
catch (MessagingException e){}
}
}.start();
Log.i("email","发送成功");
}catch(Exception e){
Log.e("email","发送失败");
}
}