1
我試圖創建一個頁面,它在Play Framework上發送帶附件的電子郵件。我首先需要知道如何發送簡單的電子郵件。我正在關注 Apache Commons Userguide for Email。播放框架使用Apache Commons發送電子郵件
Email email = new SimpleEmail();
email.setHostName("smtp-mail.outlook.com");
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("[email protected]", "password"));
email.setSSLOnConnect(true);
email.setFrom("[email protected]");
email.setSubject("Subject");
email.setMsg("This is a test mail ... :-)");
email.addTo("[email protected]");
email.send();
執行異常:[EmailException: Sending the email to the following server failed : smtp-mail.outlook.com:465]
我不知道爲什麼它說465
即使我設定的端口作爲終端587
例外:Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp-mail.outlook.com, 465; timeout 60000;
是什麼程序接受的原因端口號爲465
。當我用gmail