[jboss-user] [Beginners Corner] - JavaMail in servlet can't find smtp host.
vondart
do-not-reply at jboss.com
Mon Aug 7 08:29:38 EDT 2006
Following is the code, the error message is "can't find smtp host", but I can receive Mail with my code, who can tell me why?
Thanks.
+++++++++++++++++++++++++++++++++++++++++++++
public class Servlet1
extends HttpServlet {
static class BasicAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication( ) {
return new PasswordAuthentication("myname", "mypw");
}
}
private static final String CONTENT_TYPE = "text/html; charset=GBK";
InitialContext cxt;
Session sess,sess1;
public void init() throws ServletException {
try{
Properties p = System.getProperties();
p.put("mail.smtp.host", "smtp.126.com");
cxt=new InitialContext();
sess1=(Session)cxt.lookup("java:comp/env/mail/DefaultMail");
sess= sess1.getInstance(p,new BasicAuthenticator());
Message msg = new MimeMessage(sess);
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963550#3963550
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963550
More information about the jboss-user
mailing list