Merry Christmas,
I have a problem with mail in my servlet. It works fine when I test it with
one Internet service provider but not with another. The problem seems to be
with the smtp host but I don't know why it will not work. The odd part of it
is the example programs work fine but the code that is in my servlet
doesn't. Any clues? ...here is the code in my servlet (its just like one of
the samples in java mail).
//////////////////////////// Mail configuration //////////////////////////
if(!(email.equals("")) && (action.equals("step2"))){
String msgText = "Thank you for doing business with my
company.\n";
String from = "Tom";
String host = "mailhost.worldnet.att.net";
boolean debug = Boolean.valueOf("true").booleanValue();
// create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", host);
if (debug) props.put("mail.debug", "true");
javax.mail.Session emailSession =
javax.mail.Session.getDefaultInstance(props, null);
emailSession.setDebug(debug);
try {
// create a message
Message msg = new MimeMessage(emailSession);
msg.setFrom(new InternetAddress(from));
//InternetAddress[] emailAddress = {new
InternetAddress(to)};
InternetAddress[] emailAddress = {new
InternetAddress(email)};
msg.setRecipients(Message.RecipientType.TO,
emailAddress);
msg.setSubject("your i.d. number");
msg.setSentDate(new java.util.Date());
// If the desired charset is known, you can use
// setText(text, charset)
msg.setText(msgText);
Transport.send(msg);
} catch (MessagingException mex) {
System.out.println("\n--Exception Submit's Email");
System.out.println("Email is = to " + email);
}
}
////////////////////////// End Mail configuration
//////////////////////////
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html