我试图阅读公司特定生成的电子邮件服务器的电子邮件,这是我的代码,我无法与服务器建立连接,因为它是Linux服务器。
public class Testing {
public static void main(String[] args) {
String from = "email";
String pass = "pwd";
String to = "toId";
String host = "pop.zoho.com";
String port = "995";
Properties properties = System.getProperties();
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.user", from);
properties.put("mail.smtp.password", pass);
properties.put("mail.smtp.port", "995");
properties.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(properties);
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("This is the Subject Line!");
message.setText("This is actual message");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("Sent message successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
请提供全面的帮助 提前谢谢