Jsp中如何发送 邮件啊?我做了一个有问题啊?请教高手???

解决方案 »

  1.   

    <%@page import="java.util.*"%>
    <%@page import="javax.mail.*"%>
    <%@page import="javax.mail.internet.*"%><%
      Properties props = new Properties();
      props.put("mail.smtp.host", "smtp.mail.example.com");
      
      Session s = Session.getInstance(props, null);
      MimeMessage message = new MimeMessage(s);
      InternetAddress from = new InternetAddress(" [email protected] e-mail address is being protected from spam bots, you need JavaScript enabled to view it ");
      message.setFrom(from);
      
      InternetAddress to = new InternetAddress(" [email protected] e-mail address is being protected from spam bots, you need JavaScript enabled to view it ");
      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="sendmail.jsp">Click here to send another!</a>
    </p>
    </html>