javamail~~?

  • Thread starter albert85 via JavaKB.com
  • Start date
A

albert85 via JavaKB.com

i want to know what javamail can do wat is it?
what te advantages for using the javamail?
what the differences between javamail and normal e-mail?????
 
R

Roedy Green

i want to know what javamail can do wat is it?
what te advantages for using the javamail?
what the differences between javamail and normal e-mail?????

JavaMail sends and receives emails to a ordinary STMP/POP3 mail
server. It is just a set of methods you can use to automate mail
tasks. You could use it for example to write a multiplatform email
program similar to Eudora.

I used it for example to write bulk mailer, then sends the same
message to many people, validating all the email addresses and
reporting on problems.

See http://mindprod.com/products1.html#BULK

Read the tutorial. It actually pretty easy. The JavaDoc is not very
useful until you understand how all the pieces fit together. It gives
you the code to create and unpack attachments and fiddle with the
various header fields.
 
Z

zero

Read the tutorial. It actually pretty easy. The JavaDoc is not very
useful until you understand how all the pieces fit together.

That is true for a lot of the more exotic parts of the java library, and
many third party libraries as well. Javadoc should include more code
samples.

Writing good documentation is almost as hard as writing good code.
 
O

opalpa

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)
 
T

Thomas Weidenfeller

zero said:
That is true for a lot of the more exotic parts of the java library, and
many third party libraries as well. Javadoc should include more code
samples.

JavaMail comes with a whole directory of example code. Why clutter the
documentation with that? The only thing IMHO missing in JavaMail's
javadoc are pointers to these examples - for those programmers who don't
check what they actually installed.

/Thomas
 
Z

zero

The only thing IMHO missing in JavaMail's
javadoc are pointers to these examples

That would work too. For example a lot of the Swing GUI classes have links
to the (very good) Swing tutorial. That is a very good solution imo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top