我刚刚注册的一个 sina 的邮箱。
想要实现发送邮件的功能, 可是一直都连接不上,
代码如下:
try {
Properties props = new Properties();
props.put("mail.smtp.host", mailserver);
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props,
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
}
);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(fromAddr));
InternetAddress[] tos = InternetAddress.parse(toAddr);
msg.setRecipients(Message.RecipientType.TO, tos);
msg.setSubject(subject);
Transport.send(msg);
System.out.println("Mail is Sent");
}
catch (Exception e) {
System.out.println(e);
} }
想要实现发送邮件的功能, 可是一直都连接不上,
代码如下:
try {
Properties props = new Properties();
props.put("mail.smtp.host", mailserver);
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props,
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
}
);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(fromAddr));
InternetAddress[] tos = InternetAddress.parse(toAddr);
msg.setRecipients(Message.RecipientType.TO, tos);
msg.setSubject(subject);
Transport.send(msg);
System.out.println("Mail is Sent");
}
catch (Exception e) {
System.out.println(e);
} }
.........
String POP3server = "pop.163.com";
String SMTPserver = "smtp.163.com";
Session mailsession = null;
Store store;
Folder folder;
Message[] messages = null;
final String username;
final String password;
username = request.getParameter("user");
password = request.getParameter("password");
java.util.Properties properties = System.getProperties();
properties.put("mail.smtp.host", SMTPserver);
properties.put("mail.smtp.auth", "true");
.........
我试过163 的了 不好使阿 我的那个既不是付费的 也不是vip
我就想找一个支持smtp的邮箱 一直找不到真愁人
这是运行之后那条错误信息
mailsession = Session.getInstance(properties, new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});