人们一般都是会放到jsp里就会用,其它地方不会用,你怎么是这样呀,哈哈

解决方案 »

  1.   

    给你,记得给我分!!!!!!
    <%@ page import=" javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*" %>
    <%@ page import="javamail.SmtpAuthenticator"%>
    <html>
    <head>
    <TITLE>JSP meets JavaMail, what a sweet combo.</TITLE>
    </HEAD>
    <BODY>
    <%
    try{
    Properties props = new Properties();
    Session sendMailSession;
    Store store;
    Transport transport;
    //sendMailSession = Session.getInstance(props, null);
    props.put("mail.smtp.host", "smtp.tom.com");
    props.put("mail.smtp.auth", "true");
    SmtpAuthenticator sa = new SmtpAuthenticator("[email protected]","password");
    sendMailSession = Session.getInstance(props, sa);
    Message newMessage = new MimeMessage(sendMailSession);
    newMessage.setFrom(new InternetAddress(request.getParameter("from")));
    newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(request.getParameter("to")));
    newMessage.setSubject(request.getParameter("subject"));
    newMessage.setSentDate(new Date());
    newMessage.setText(request.getParameter("text"));
    transport = sendMailSession.getTransport("smtp");
    transport.send(newMessage);
    %>
    <P>Your mail has been sent.</P>
    <%
    }
    catch(MessagingException m)
    {
    out.println(m.toString());
    }
    %>
    </BODY>
    </HTML>
      

  2.   

    F:\Tomcat\Tomcat 4.1\work\Standalone\localhost\800\deal_jsp.java:11: package javamail does not exist
    import javamail.SmtpAuthenticator;
                    ^
    F:\Tomcat\Tomcat 4.1\work\Standalone\localhost\800\deal_jsp.java:63: cannot resolve symbol
    symbol  : class SmtpAuthenticator 
    location: class org.apache.jsp.deal_jsp
    SmtpAuthenticator sa = new SmtpAuthenticator("timehours","801114");好象是找不到 SmtpAuthenticator 这个类,因为是  <%@ page import="javamail.SmtpAuthenticator"%> 这怎么办啊?
      

  3.   

    这是我自己写的类,晕,你可以自己写呀,我只是告诉你在jsp中如何用,哈
      

  4.   

    晕,看来我要大出血了,好给你吧package javamail;import javax.mail.Authenticator;
    import javax.mail.*;public class SmtpAuthenticator extends Authenticator {
       String userName;
       String userPassword;   public SmtpAuthenticator(String userName, String userPassword) {
         this.userName = userName;
         this.userPassword = userPassword;
       }   protected PasswordAuthentication getPasswordAuthentication() {
         return new PasswordAuthentication
             (userName, userPassword);
       }
     }
    记得给我分呀,哈哈,我缺分呀,哈
      

  5.   

    其实就是需要做一下证明,就象咱们用foxmail一样要把点选“需要通过验证”,哈