0
如何使用javax.mail發送郵件jsp中的API我正在得到像這樣的錯誤,所以請告訴我爲什麼我遇到問題或我需要做什麼。在jsp中發送電子郵件時出錯
An error occurred at line: 6 in the jsp file: /mails.jsp
Session cannot be resolved to a type
3: String host = "pushkalit.in";
4: Properties prop = new Properties();
5: prop.put("mail.smtp.host", host);
6: Session s = Session.getInstance(prop,null);
7: MimeMessage message = new MimeMessage(s);
8:
9: InternetAddress from = new InternetAddress("[email protected]");
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*, javax.mail.Session.*" %>
<%
String host = "pushkalit.in";
Properties prop = new Properties();
prop.put("mail.smtp.host", host);
Session s = Session.getInstance(prop,null);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("[email protected]");
message.setFrom(from);
InternetAddress to = new InternetAddress("[email protected]");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
Transport.send(message);
%>
<html>
<p align="center">A Message has been sent.<br>Check your inbox.</p>
<p align="center"><a href="mailjavax.jsp">Click here to send another!</a></p>
</html>
您的SMTP服務器沒有按不需要認證? –
需要驗證 –