wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes javamail problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "javamail problems" Watch "javamail problems" New topic

javamail problems

Tom Boyce

Joined: Jul 03, 2003
Posts: 24
Hey all,
I'm attempting to set up an automated monitoring program that will test connections to some db's, ping various servers to see if alive and other connection testing. The successful results will be written to a log and the unsuccessful attempts will generate an email to a help desk. I have a connections, ping-ing and logging set up, but I'm having some trouble with the mail. I have downloaded the javamail and javabean requirements and installed them. I have replace the real email address below with fictious, but in my program the email address are real. Can anyone provide some guidance?
Here is my classpath: .;C:\JBuilder9\jdk1.4\lib\tools.jar;%CATALINA_HOME%\common\lib\servlet.jar;c:\javamail-1.3.1\mail.jar;c:\jaf-1.0.1\activation.jar;c:\javamail-1.3.1\lib\imap.jar;c:\javamail-1.3.1\lib\mailapi.jar:c:\javamail-1.3.1\lib\pop3.jar;c:\javamail-1.3.1\lib\smtp.jar
I also have copied each jar file into every conceviable directory. IN addition, I have configured the libararies in JBuilder. Here is my code:
// method to send an email
public void monitorEmail ()
String to = "someone@nowhere.com";
String from = "me@nowhere.com";
String host = "mail.nowhere.com";
// Create properties, get Session
Properties props = new Properties();
// If using static Transport.send(),
// need to specify which host to send it to
props.put("mail.nowhere.com", host);
// To see what is going on behind the scene
props.put("mail.debug", "true");
Session session = Session.getInstance(props);
try {
// Instantiatee a message
Message msg = new MimeMessage(session);
//Set message attributes
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test E-Mail through Java");
msg.setSentDate(new Date());
// Set message content
msg.setText("This is a test message for the monitor program" +
"to test for a oracle connection. Testing a failed" +
"connection. This is only a test!");
//Send the message
catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
And Finally, here is the debug trace:
DEBUG: JavaMail version 1.3.1
DEBUG: java.io.FileNotFoundException: C:\JBuilder9\jdk1.4\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: URL jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/imap.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/imap.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/pop3.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/pop3.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/smtp.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/smtp.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/javamail-1.3.1/lib/imap.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/javamail-1.3.1/lib/imap.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/javamail-1.3.1/lib/pop3.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/javamail-1.3.1/lib/pop3.jar!/META-INF/javamail.providers
DEBUG: URL jar:file:/C:/javamail-1.3.1/lib/smtp.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: jar:file:/C:/javamail-1.3.1/lib/smtp.jar!/META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: URL jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/smtp.jar!/META-INF/javamail.address.map
DEBUG: successfully loaded resource: jar:file:/C:/JBuilder9/jdk1.4/jre/lib/ext/smtp.jar!/META-INF/javamail.address.map
DEBUG: URL jar:file:/C:/javamail-1.3.1/lib/smtp.jar!/META-INF/javamail.address.map
DEBUG: successfully loaded resource: jar:file:/C:/javamail-1.3.1/lib/smtp.jar!/META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: C:\JBuilder9\jdk1.4\jre\lib\javamail.address.map (The system cannot find the file specified)
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "localhost", port 25

220 tboyce Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Mon, 19 Apr 2004 21:28:17 -0400
DEBUG SMTP: connected to host "localhost", port: 25

EHLO tboyce
250-tboyce Hello []
250-SIZE 2097152
250 OK
DEBUG SMTP: Found extension "AUTH", arg "GSSAPI NTLM LOGIN"
DEBUG SMTP: Found extension "AUTH=LOGIN", arg ""
DEBUG SMTP: Found extension "SIZE", arg "2097152"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "8bitmime", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "OK", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<me@nowhere.com>
250 2.1.0 me@nowhere.com....Sender OK
RCPT TO:<someone@nowhere.com>
550 5.7.1 Unable to relay for someone@nowhere.com
DEBUG SMTP: Invalid Addresses
DEBUG SMTP: someone@nowhere.com
DEBUG SMTP: Sending failed because of invalid destination addresses
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for someone@nowhere.com

at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at Monitor.connTask.monitorEmail(connTask.java:94)250 2.0.0 Resetting
at Monitor.connTask.run(connTask.java:41)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
Jammy Wells

Joined: Oct 04, 2007
Posts: 17

I am also facing the same problem , did you get any clue to resolve this...
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41068
You've replied to a post that is 3 years old: DontWakeTheZombies

Tom last posted on JavaRanch in September 2004, so I think it's safe to say that he won't be seeing your question.

Ping & DNS - my free Android networking tools app
I agree. Here's the link: http://aspose.com/file-tools
subject: javamail problems
Similar Threads
SMTP(Simple Mail Transer Protocol)
Must issue a starttls command
the mails are goes to Badmail folder of the host
JavaMail not sending emails all the time
Not able to access Email account