Just a comment, althought not perfect, I find the amount of free and
quality Java examples to be above other systems I've worked on. I
think the examples that do exist are of unusually high quality. They
are way above Apple C examples, way above C# examples on ... forget the
site now... and Java code is usually much more readable then C++ and
many other languages.
So much quality & free stuff.
The moral of the story is look for examples when Javadoc is inadaquate.
If you define the following variables as String: username, password,
SMTP_HOST_NAME, SMTP_PORT, SSL_FACTORY, assign appropriate values, and
also somewhere in the code, before invocation, put
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); the
following will send emails for you:
public void sendSSLMessage(String recipients[], String subject,
String message, String from) throws MessagingException {
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "false");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication
getPasswordAuthentication() {
return new PasswordAuthentication(username,
password);
}
});
session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new
InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo
= new InternetAddress(recipients);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
Have a fun day, http://www.geocities.com/opalpaweb/, (e-mail address removed)