Is javamail for me?

Project:
Creating a java program which shows images on the screen and some
buttons below them. What I plan to do is, when the button is pressed, a new
web page comes up and lets the user know what they have ordered. On the
new page, for them to send this information to me, they hit the "send" button.
My questions:
Once the send button is hit, do you think javamail would be able to handle this?
If so, does the user have to have javamail on their system. Do they have to
have an email account or can I use mine to send the page to me? I've checked
out the javamail tutorial and it seems to contradict itself as to the purpose.

Yes, it was. It had seemed that this area was pretty dead and me being a
newby should post this in the newby area. Sorry if I caused any
inconvenience.

Similar Messages

  • Can anyone give me a bean class for JAVAMAIL, for using in JSP?

    Can anyone give me a bean class for JAVAMAIL, for using in JSP?
    I hate coding everything inside a jsp page!! Anyone out there who can help me out??

    hi
    see my post in the javamail forum... here you can see a bean.. I'm trying to connect it with the mysql database - may you can help me

  • Need to setup javamail for testing

    Hi team, I am new to Java. I am not able to compile javamail application. I download javamail-1.4.1 and jaf-1.0.2 under c:\.
    I was update a classpath like this.
    .;C:\j2sdk1.4.2_16\bin;c:\javamail-1.4.1\mail.jar;c:\jaf-1.0.2\activation\activation.jar.
    Here is my program
    public static void main(String[] args) {
    // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
    String to = "[email protected]";
    String from = "[email protected]";
    // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
    String host = "mail.yahoo.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.smtp.host", 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 of sending a " +
    "plain text e-mail through Java.\n" +
    "Here is line 2.");
    //Send the message
    Transport.send(msg);
    catch (MessagingException mex) {
    // Prints all nested (chained) exceptions as well
    mex.printStackTrace();
    }//End of class
    When i compile this program i am getting below message
    C:\Documents and Settings\Administrator\Desktop\Applet>javac TestEmail.Java
    javac: invalid flag: TestEmail.Java
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are used
    -classpath <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -help Print a synopsis of standard options
    Please suggest and correct me on this.
    Thanks in Advance

    Hopefully it was clear from the error message that javac didn't even try to
    compile your program. Perhaps you need to name your file "TestEmail.java"
    instead of "TestEmail.Java"?
    Also, if you're still using JDK 1.4.2, it's way past time to upgrade. JDK 1.6 has
    been available for a long time. And you don't need the JDK directory in your
    CLASSPATH.
    Finally, double check that the mail.jar and activation.jar files exist at the
    locations you used in your CLASSPATH. That's not your current problem,
    but it will be important later.

  • How to use Javamail for accessing additional mailboxes -IMAP, Exchange 2010

    hi,
    I want to access a shared mailbox (NOT FOLDER) via Javamail API (1.4.5) using IMAP(s) with plain logon. The mailserver is a Exchange Server 2010.
    User: user1 ([email protected])
    pwd: xxxx
    shared mailbox: [email protected]
    Properties:
    mail.imaps.socketFactory.port = 993
    mail.imaps.starttls.enable = true
    mail.imaps.socketFactory.class = javax.net.ssl.SSLSocketFactory
    mail.imaps.socketFactory.fallback = false
    username = [email protected]
    password = xxxx
    I´ve managed to get access to the user1 - mailbox:
    Session session = Session.getInstance(properties, new ExchangeAuthenticator(username, password));
    session.setDebug(true);
    Store store = session.getStore("imaps");
    store.connect(imapHost, username, password);
    --> this works just fine! But now i want to access the additional mailbox by changing the login-String:
    [email protected]/shared_MB (user@domain/additional_MB)
    --> unfortunately I´m getting an "NO AUTHENTICATE" message:
    DEBUG: setDebug: JavaMail version 1.4.5
    DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
    DEBUG: mail.imap.fetchsize: 16384
    DEBUG: mail.imap.statuscachetimeout: 1000
    DEBUG: mail.imap.appendbuffersize: -1
    DEBUG: mail.imap.minidletime: 10
    DEBUG: trying to connect to host "host.domain.com", port 993, isSSL true
    * OK The Microsoft Exchange IMAP4 service is ready.
    A0 CAPABILITY
    * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
    A0 OK CAPABILITY completed.
    DEBUG IMAP: AUTH: NTLM
    DEBUG IMAP: AUTH: GSSAPI
    DEBUG IMAP: AUTH: PLAIN
    DEBUG: protocolConnect login, host=host.domain.com, [email protected]/shared_MB, password=<non-null>
    DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed
    DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO AUTHENTICATE failed.
    javax.mail.AuthenticationFailedException: AUTHENTICATE failed.
    I was able to get access with Thunderbird and also with the Exchange OWA-Client, so I think there is something missing in my code...
    or is it just impossible to get access to a different mailbox using javamail and plain-auth?
    Thank you in advance.

    Thanks bshannon, that was a great idea!
    I haven´t found an solution yet, but I have maybe identified the real problem:
    Here is some interessting Thunderbird - Logging stuff:
    744[7161040]: try to log in
    744[7161040]: IMAP auth: server caps 0x1187235, pref 0x1006, failed 0x0, avail caps 0x1004
    744[7161040]: (GSSAPI = 0x1000000, CRAM = 0x20000, NTLM = 0x100000, MSN = 0x200000, PLAIN = 0x1000, LOGIN = 0x2, old-style IMAP login = 0x4)auth external IMAP login = 0x20000000
    744[7161040]: trying auth method 0x1000
    744[7161040]: got new password
    744[7161040]: IMAP: trying auth method 0x1000
    744[7161040]: PLAIN auth
    744[7161040]: 7082000:xmail.domain.com:NA:SendData: 2 authenticate plain
    744[7161040]: ReadNextLine [stream=7ec9e88 nb=3 needmore=0]
    744[7161040]: 7082000:xmail.domain.com:NA:CreateNewLineFromSocket: +
    744[7161040]: 7082000:xmail.domain.com:NA:SendData: Logging suppressed for this command (it probably contained authentication information)
    744[7161040]: ReadNextLine [stream=7ec9e88 nb=27 needmore=0]
    744[7161040]: 7082000:xmail.domain.com:NA:CreateNewLineFromSocket: 2 NO AUTHENTICATE failed.
    744[7161040]: authlogin failed
    744[7161040]: marking auth method 0x1000 failed
    ---> okay, so PLAIN AUTH is failing.....
    744[7161040]: IMAP auth: server caps 0x1187235, pref 0x1006, failed 0x1000, avail caps 0x4
    744[7161040]: (GSSAPI = 0x1000000, CRAM = 0x20000, NTLM = 0x100000, MSN = 0x200000, PLAIN = 0x1000, LOGIN = 0x2, old-style IMAP login = 0x4)auth external IMAP login = 0x20000000
    744[7161040]: trying auth method 0x4
    744[7161040]: got new password
    744[7161040]: IMAP: trying auth method 0x4
    744[7161040]: old-style auth
    744[7161040]: 7082000:xmail.xmail.domain.com:NA:SendData: Logging suppressed for this command (it probably contained authentication information)
    744[7161040]: ReadNextLine [stream=7ec9e88 nb=23 needmore=0]
    744[7161040]: 7082000:xmail.domain.com:NA:CreateNewLineFromSocket: 4 OK LOGIN completed.
    744[7161040]: login succeeded
    --> okay, so Thunderbird is using "old-style IMAP login" and is successful.
    Unfortunately I have no idea what that actually means or how to use it in Javamail (is it even supported?). Any suggestions?

  • JavaMail for receiving mail?

    I've used JavaMail in the past, but always as a client sending SMTP messages. Now I have a need to write a specialized app for receiving mail, processing it, and then sending it as an SNMP trap.(using API's from something like Trap Console)
    We have systems on our network that do not have the ability to send SNMP traps and that is our primary way of getting information about problems.
    Anyway, can I use JavaMail to write a server that will listen on port 25 like a standard SMTP mail server and receive mail so I can process it another way?
    Are there any code samples available anywhere for receiving mail?
    Thanks,
    James

    I don't know if this will help but you might want to take a look at james. Here's more info:
    http://james.apache.org/index.html

  • Javamail for Netscape

    Hello all....
    I'm trying to devise a way to have the user fill out a form, and then send this form to a JSP and mail the data to a coworker.
    The JavaMail API seems like an absolutely wonderful way to go, but here's the problem: JavaMail is not supported by Netscape, due to restrictions by Netscape (info about that: http://java.sun.com/products/javamail/FAQ.html#browsers ). The Sun site recommends using the Java Plug-In, but nowhere in their documentation can I find any info on sending mail.
    Being a government project, I unfortunately HAVE to support both Netscape and Explorer. Any ideas? Ways to use the Java Plug-In for mail? Alternative methods? Any feedback would be appreciated.

    That seems like a logical conclusion to me, but here's a snippet from the JavaMail FAQ that I linked to above:
    Q: Do the JavaMail APIs work in web browsers?
    A: We have successfully run in the HotJava TM Browser and Internet Explorer. JavaMail APIs won't work in Netscape Communicator due to their restrictions on resources that can be accessed. (Although you can use the Java Plug-in with Netscape.)
    It seems to me that this is saying you can't run a JSP using JavaMail on a Netscape brower. Am I misinterpreting this?

  • Is there any limit of JavaMail for sending mails?

    When am sending more than 700 mails at a time then error appears that "server is too busy please try again"
    Is there any deficiency in my code or limitations in JavaMail ?
    Thanks & best regards

    The limitation is in your server.

  • Error while using Javamail...pls help me...

    when i am using javamail for sending mail , i am getting error like,
    C:\jdk1.3\bin\mail>java MailSend
    [email protected] [email protected]
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.MessagingException:
    at javax.mail.Transport.send0(Transport.java:218)
    at javax.mail.Transport.send(Transport.java:80)
    at MailSend.Send(MailSend.java:56)
    at MailSend.main(MailSend.java:73)
    and i define properties like,
    mailProp.put("java", "java");
    where , "java" is my system name, and there is also mail server on my system. and my system is connected with proxy server..
    when i am trying
    mailProp.put("mail.smtp.host", "java");
    then i am getting same type of error...
    so, what is that ? pls help me to solve my error...

    Surely there's more information associated with that MessaginException than
    you've included here.
    Turn on session debugging and run your program again.
    http://java.sun.com/products/javamail/FAQ.html#debug

  • Sending fax using javaMail

    Hi,
    Iam working on an assignment where I should be able to send a page via email or efax. Iam using JavaMail for email. Not sure what to do for the Fax.
    Someone help me.
    Thanks
    Jo

    I think you have to write thr protocol yourself for eFax just search for it and you will hopefully find som info how the protocol is built!
    .leonard

  • Using JSF and JavaMail to send Automated Email

    Hi All,
    Can any one please suggest I can use JSF and JavaMail to send automated email messages i.e after a person has successfully completed a form , a message is sent to his/her email address confirming that he has succesfully registered or completed a form. I have succesfull implemeted the use of javamail for sending email meassages in a JSF web application but cant seem to figure out how i can achieve automated sending of emails in JSF. Please any ideas, tutorials or source code would be very much appreciated.
    Thanks.

    I don't understand your problem:
    You have already been able to send e-mails from a JSF webapplication, but you are not capable of sending e-mails from a JSF webapplication?!
    Automated sending of e-mails will be exactly the same as non-automated.

  • SMTPSendFailedException: 550 : your email program is used for spam

    I'm using javamail for quite a long time, but recently I sometimes receive this error while sending a mail.
    SMTPSendFailedException: 550 Error: You used an email program that is used almost exclusively for spam.
    If using Outlook , I have no problem sending to the same address, using the same SMTP.
    I suppose the 'javamail' in the message ID is responsible for this.
    Anyone else with same problem, any ideas on how to avoid this?

    You should talk to the administrator of your mail server and find out
    what it's matching on to determine this. If it's the message ID, you can
    change the message ID to whatever you want.
    I assume, of course, that you're not actually sending spam...

  • Here's how you use JavaMail in a Netscape 4.x applet

    First of all... Sun has said that they are working on patching JavaMail for the next minor release so that it will be usable with Netscape.
    But for those with itchy pants... here's how you do to send mail from a Netscape 4.x applet without using the Java Plug-in.
    First of all... you'll need to sign the applet. Now I'm not so good with singing tools so I don't know if Netscape 4.x allows using Sun's signing tools. I used Netscapes own "signtool" just to be sure.
    You'll need to unjar activation.jar and mail.jar (or mailapi.jar plus smtp.jar). Use signtool to sign and jar your own classfiles plus those from the jar-files mentioned.
    This creates a small problem though: atcivation.jar and mail.jar has files in the META-INF directory. Netscapes signtool ignores these files. So you'll have to patch around that.
    Using the "sendfile.java" demo as basis... here's how you deal with the missing configuration files.
        // You'll have to request this privilige or Netscape will bolt on you.
        // If you need cross-platfor compatibility you'll need to wrap this up or IE
        // will be really cranky at this. Try by doing something you know
        // IE accepts but that Netscape don't. Catch the  exception as just an
        // Exception and do the following in the catch.
        try {
          PrivilegeManager.enablePrivilege("UniversalPropertyRead");
        } catch (netscape.security.ForbiddenTargetException e2) {
          System.out.println("Failed! Permission to read system properties denied by user.");
        } catch (Exception e2) {
          System.out.println("Failed! Unknown exception while enabling privilege.");
          e2.printStackTrace(System.out);
        // create some properties and get the default Session
        Properties props = null;
        props = System.getProperties();
        props.put("mail.smtp.host", mailhost);
        // The mailcap command map needs a missing
        // config file. So you'll have to hardwire the different
        // commands like this.
        javax.activation.MailcapCommandMap commandMap = new javax.activation.MailcapCommandMap();
        commandMap.addMailcap("text/plain;;          x-java-content-handler=com.sun.mail.handlers.text_plain");
        commandMap.addMailcap("text/html;;          x-java-content-handler=com.sun.mail.handlers.text_html");
        commandMap.addMailcap("text/xml;;          x-java-content-handler=com.sun.mail.handlers.text_xml");
        commandMap.addMailcap("multipart/*;;          x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
        commandMap.addMailcap("message/rfc822;;     x-java-content-handler=com.sun.mail.handlers.message_rfc822");
        commandMap.addMailcap("image/gif;;          x-java-view=com.sun.activation.viewers.ImageViewer");
        commandMap.addMailcap("image/jpeg;;          x-java-view=com.sun.activation.viewers.ImageViewer");
        commandMap.addMailcap("text/*;;          x-java-view=com.sun.activation.viewers.TextViewer");
        commandMap.addMailcap("text/*;;          x-java-edit=com.sun.activation.viewers.TextEditor");
        javax.activation.MailcapCommandMap.setDefaultCommandMap(commandMap);
        // Now here is a really weird thing. This class - MimeUtility - will
        // be used later on. But the ClassLoader in Netscape seems
        // to be broken. I downloaded J2EE and fiddled with this class a bit.
        // It seems that the following line will get you around this problem.
        Object o = MimeUtility.class;
        try {
          // create a message
          Session session = Session.getDefaultInstance(props, null);
          session.setDebug(true);
          MimeMessage msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(from));
          InternetAddress[] address = {new InternetAddress(to)};
          msg.setRecipients(Message.RecipientType.TO, address);
          msg.setSubject("Message from scratchpad");
          // create and fill the first message part
          MimeBodyPart mbp1 = new MimeBodyPart();
          mbp1.setText(message);
          // create the second message part
          MimeBodyPart mbp2 = new MimeBodyPart();
          // attach the file to the message
          // This is not the same as the original.
          // The ByteArrayDataSource class helps you attach an arbitrary file-type.
          // The code for that is found here:
          // http://forums.java.sun.com/thread.jsp?forum=43&thread=73819
          DataSource ds = new ByteArrayDataSource(imageData, "image/gif", "image.gif");
          mbp2.setDataHandler(new DataHandler(ds));
          mbp2.setFileName("image.gif");
          // create the Multipart and its parts to it
          Multipart mp = new MimeMultipart();
          mp.addBodyPart(mbp1);
          mp.addBodyPart(mbp2);
          // add the Multipart to the message
          msg.setContent(mp);
          // set the Date: header
          msg.setSentDate(new Date());
          // send the message
          // Transport.send() will give you exception in Netscape.
          // Here is how you do what that method does.
          msg.saveChanges();
          com.sun.mail.smtp.SMTPTransport transport = new com.sun.mail.smtp.SMTPTransport(session, null);
          transport.connect();
          transport.sendMessage(msg, address);
          transport.close();     
        catch (MessagingException mex) {
          mex.printStackTrace();
          Exception ex = null;
          if ((ex = mex.getNextException()) != null) {
            ex.printStackTrace();
        }Enjoy
    /Michael

    Typical... i knew I'd fumble. There is one more thing you need to do.
    Download J2EE, source code edition and patch the file javax.mail.internet.MimeUtility.java
    Change the line
    InputStream is = javax.mail.internet.MimeUtility.class.getResourceAsStream("/META-INF/javamail.charset.map");...to...
    InputStream is = javax.mail.internet.MimeUtility.class.getResourceAsStream("/javamail.charset.map");Also, after you unjar the jarfiles and before you run the signtool, move the file META-INF/javamail.charset.map to the partent of the META-INF directory.
    /Michael

  • Problems with javamail

    Hello,
    I am trying to use javamail, for sending emails and I am using NetBeans as the IDE, and IIS as the webserver.
    I found a code online, from this webpage: http://www.javacommerce.com/displaypage.jsp?name=javamail.sql&id=18274
    The webserver runs fine, and the code runs fine too, but the email doesnt get sent. maybe what parameters I pass are wrong, so I am attaching my code as well.
    package emailexample;
    import
    com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingExcep
    tion;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class Main {
    public static void postMail( String recipients[ ],
            String subject,
            String message ,
            String from) throws javax.mail.MessagingException
        boolean debug = false;
         //Set the host smtp address
         Properties props = new Properties();
         //props.put("mail.smtp.host", "localhost");
         props.put("mail.smtp.host", "localhost");
        // create some properties and get the default Session
        Session session = Session.getDefaultInstance(props, null);
        session.setDebug(debug);
        // create a message
        Message msg = new MimeMessage(session);
        // set the from and to address
        InternetAddress addressFrom;
            try {
                addressFrom = new InternetAddress(from);
        msg.setFrom(addressFrom);
        InternetAddress[] addressTo = new InternetAddress[recipients.length];
        for (int i = 0; i < recipients.length; i++)
            addressTo[i] = new InternetAddress(recipients);
    msg.setRecipients(Message.RecipientType.TO, addressTo);
    // Optional : You can also set your custom headers in the Email if you Want
    msg.addHeader("MyHeaderName", "myHeaderValue");
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
    } catch (AddressException ex) {
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    public static void main(String[] args) {
    try {
    postMail(new String[]{"[email protected]"},
    "testing java mail", "see it works :)",
    "[email protected]");
    } catch (javax.mail.MessagingException ex) {
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    can someone please help?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    The JavaMail FAQ has tips for debugging, pointers to sample programs, and much more. Start there.
    In particular, a protocol trace will help us figure out what's not working.

  • Evaluating debug src, and 'Unable to relay for ...'

    hello.
    i wanted to know if there is any possibility to evaluate the string that is returned using debug mode in javamail. for example to know wheter conn to mailserver was ok. wether sender or recipient was ok and so on.so that i can (for example) build in some if-clauses to stop (and give a mesage to the current user 'conn failed') or retry some processes.
    my second question is, that i sometimes get an error sending mails. the app is running on a tomcat server (localhost). after restarting the tomcat, it works again. after a while (2 or 3 days) it gives me the error message again ('Unable to relay for')here is my exception:
    ###################### debug/exception start ######################
    DEBUG: getProvider() returning
    javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
    Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG: SMTPTransport trying to connect to host "localhost", port 25
    DEBUG SMTP RCVD: 220 ffmserver.mailabc.local Microsoft ESMTP MAIL Service,
    Version: 5.0.2195.6713 ready at Mon, 3 Apr 2006 13:17:02 +0200
    DEBUG: SMTPTransport connected to host "localhost", port: 25
    DEBUG SMTP SENT: EHLO ffmserver
    DEBUG SMTP RCVD: 250-ffmserver.mailabc.local Hello [127.0.0.1]
    250-AUTH GSSAPI NTLM LOGIN
    250-AUTH=LOGIN
    250-TURN
    250-ATRN
    250-SIZE 2097152
    250-ETRN
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-8bitmime
    250-BINARYMIME
    250-CHUNKING
    250-VRFY
    250 OK
    DEBUG SMTP Found extension "AUTH", arg "GSSAPI NTLM LOGIN"
    DEBUG SMTP Found extension "AUTH=LOGIN", arg ""
    DEBUG SMTP Found extension "TURN", arg ""
    DEBUG SMTP Found extension "ATRN", arg ""
    DEBUG SMTP Found extension "SIZE", arg "2097152"
    DEBUG SMTP Found extension "ETRN", arg ""
    DEBUG SMTP Found extension "PIPELINING", arg ""
    DEBUG SMTP Found extension "DSN", arg ""
    DEBUG SMTP Found extension "ENHANCEDSTATUSCODES", 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
    DEBUG SMTP SENT: MAIL FROM:<[email protected]>
    DEBUG SMTP RCVD: 250 2.1.0 [email protected] OK
    DEBUG SMTP SENT: RCPT TO:<[email protected]>
    DEBUG SMTP RCVD: 550 5.7.1 Unable to relay for [email protected]
    Invalid Addresses
    [email protected]
    DEBUG SMTPTransport: Sending failed because of invalid destination addresses
    DEBUG SMTP SENT: RSET
    DEBUG SMTP RCVD: 250 2.0.0 Resetting
    DEBUG SMTP SENT: QUIT
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 550 5.7.1 Unable to relay for
    [email protected]
    at javax.mail.Transport.send0(Transport.java:219)
    at javax.mail.Transport.send(Transport.java:81)
    at
    de.mailabc.filework.beans.mail.MailSendingMsg.SendEmail(MailSendingMsg.java:115)
    at
    org.apache.jsp.jsp.dcs.lists.boxes.action.send.send_jsp._jspService(org.apache.jsp.jsp.dcs.lists.boxes.action.send.send_jsp:308)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
    at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
    at
    org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
    at
    org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 550 5.7.1 Unable to relay for
    [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:804)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:320)
    at javax.mail.Transport.send0(Transport.java:164)
    at javax.mail.Transport.send(Transport.java:81)
    at
    de.mailabc.filework.beans.mail.MailSendingMsg.SendEmail(MailSendingMsg.java:115)
    at
    org.apache.jsp.jsp.dcs.lists.boxes.action.send.send_jsp._jspService(org.apache.jsp.jsp.dcs.lists.boxes.action.send.send_jsp:308)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
    at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
    at
    org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
    at
    org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)
    ###################### exception end ######################
    any ideas
    thanks a lot
    faissal

    You don't understand that message? It's specifically mentioned in the FAQ.

  • JavaMail Gmail Exception when reading mails

    I am using JavaMail for reading messages in a gmail account.
    My general problem is validationException. My code is the following.
    public class MessagesReader {
         public static String usage = "Usage: java gmailTest user password subject";
         public static void main(String[] args) {
              String username = "username";
              String password = "password";
              Properties pop3Props = new Properties();
              Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
              pop3Props.setProperty("mail.pop3.user", username);
              pop3Props.setProperty("mail.pop3.passwd", password);
              pop3Props.setProperty("mail.pop3.ssl", "true");
              pop3Props.setProperty("mail.pop3.host", "pop.gmail.com");
              try {
                   checkForMessage(pop3Props, null);
              } catch (Exception e) {
                   e.printStackTrace();
         public static void checkForMessage(Properties props, String msgSubject)
                   throws NoSuchProviderException, MessagingException {
              Session session = null;
              Store store = null;
              String user = ((props.getProperty("mail.pop3.user") != null) ? props
                        .getProperty("mail.pop3.user") : props.getProperty("mail.user"));
              String passwd = ((props.getProperty("mail.pop3.passwd") != null) ? props
                        .getProperty("mail.pop3.passwd")
                        : props.getProperty("mail.passwd"));
              String host = ((props.getProperty("mail.pop3.host") != null) ? props
                        .getProperty("mail.pop3.host") : props.getProperty("mail.host"));
              if ((props.getProperty("mail.pop3.ssl") != null)
                        && (props.getProperty("mail.pop3.ssl").equalsIgnoreCase("true"))) {
                   String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
                   //Replace socket factory
                   props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
                   // configure the appropriate properties so JavaMail doesn't
                   // fall back to an unsecure connection when a secure one fails:
                   props.setProperty("mail.pop3.socketFactory.fallback", "false");
                   String portStr = ((props.getProperty("mail.pop3.port") != null) ? props
                             .getProperty("mail.pop3.port")
                             : "995");
                   //change the default port number to the corresponding port that your protocol's secure version uses;
                   //otherwise, you must use a fully qualified address (that includes a port number) in the URL passed
                   //to JavaMail (for example, imap://id:[email protected]:993/folder/), or else you get an
                   //"unrecognized SSL handshake" exception. You specify these properties like so:
                   props.setProperty("mail.pop3.port", portStr);
                   props.setProperty("mail.pop3.socketFactory.port", portStr);
                   URLName url = new URLName("pop3://" + user + ":" + passwd + "@"
                             + host + ":" + portStr);
                   session = Session.getInstance(props, null);
                   store = new POP3SSLStore(session, url);
                   //Unfortunately, you may realize that the code above throws an SSLException "untrusted server cert chain"
                   //if the mail server certificate is not installed locally. In that case, you should obtain a correct,
                   //valid certificate for the server and use the keytool utility to add it to a local key storage at
                   //<javahome>\jre\lib\security\cacerts.
              } else {
                   session = Session.getInstance(props, null);
                   store = session.getStore("pop3");
              session.setDebug(true);
              store.connect(host, user, passwd);
              Folder folder = store.getFolder("INBOX");
              folder.open(Folder.READ_WRITE);
              Message[] allMsgs = folder.getMessages();
              for (int i = 0; i < allMsgs.length; i++) {
                   System.out.println(allMsgs.getSubject());
              folder.close(true);
              store.close();
    When I execute the above code I get the following exception:
    [java] DEBUG: setDebug: JavaMail version 1.4ea
         [java] DEBUG POP3: connecting to host "pop.gmail.com", port 995, isSSL true
         [java] javax.mail.MessagingException: Connect failed;
         [java] nested exception is:
         [java] javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
         [java] at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)
         [java] at javax.mail.Service.connect(Service.java:275)
         [java] at javax.mail.Service.connect(Service.java:156)
         [java] at javamail.MessagesReader.checkForMessage(Unknown Source)
         [java] at javamail.MessagesReader.main(Unknown Source)
         [java] Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
         [java] at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.AppInputStream.read(DashoA6275)
         [java] at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
         [java] at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
         [java] at java.io.DataInputStream.readLine(DataInputStream.java:562)
         [java] at com.sun.mail.pop3.Protocol.simpleCommand(Protocol.java:347)
         [java] at com.sun.mail.pop3.Protocol.<init>(Protocol.java:91)
         [java] at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
         [java] at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
         [java] ... 4 more
         [java] Caused by: sun.security.validator.ValidatorException: No trusted certificate found
         [java] at sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:304)
         [java] at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:107)
         [java] at sun.security.validator.Validator.validate(Validator.java:202)
         [java] at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA6275)
         [java] at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA6275)From all the relative posts I have understood that the problem is associated with an SSL certificate. I have the gmail certificate. Taken from the padlock of the gmail browser page and so I have a gmail.cer.
    I know that I have to use a keytool to do something that I have not understand.
    Can you please give me some instructions?
    Or the forementioned exception has any other solution??
    Thanking you in advance

    Ok here.. im using this code to read from gmail too....
    * MailSender.java
    * Created on 14 November 2006, 17:07
    * This class is used to send mails to other users
    package jmailer;
    * @author Abubakar Gurnah
    import java.sql.SQLException;
    import java.util.*;
    import java.io.*;
    import java.sql.ResultSet;
    import java.text.DateFormatSymbols;
    import java.text.SimpleDateFormat;
    import javax.mail.*;
    import javax.mail.event.*;
    import javax.mail.internet.InternetAddress;
    /* Monitors given mailbox for new mail */
    class MessageRead implements Runnable{
        private String status;
        private String uname;
        private boolean serverStatus=true;
        private String serverConn;
        private int freq;
        private String account;
        private DbConn db;
        private ResultSet rsA;
        private Properties props;
        private Session session;
        private Store store;
        private Folder folder;
         * @param account get the thread account name
         * @param uname logged in user name
         * @param mailServer pop3 mail server
         * @param mailuname pop3 account username e.g [email protected]
         * @param mailPwd pop3 account password
         * @param port pop3 access port
         * @param SSL pop3 support encryption?
         * @param freq the frequency that the server will check for a new message
        public MessageRead(String account,String uname,String mailServer,String mailuname,
                String mailPwd,String port,String SSL,int freq){
            this.uname=uname;
            this.freq=freq;
            this.account=account;
            db=new DbConn();
            rsA=db.executeQuery("SELECT * " +
                    "FROM Accounts " +
                    "WHERE AccountName='" + uname + "'");
            connectToServer(uname,mailServer,mailuname,
                    mailPwd,port,SSL);
         * @param b set the thread on/off
        public void setStatus(boolean b){
            serverStatus=b;
         * @return if the server is on/off
        public boolean getStatus(){
            return serverStatus;
         * @param uname logged in user name
         * @param mailServer pop3 mail server
         * @param mailuname pop3 account username e.g [email protected]
         * @param mailPwd pop3 account password
         * @param port pop3 access port
         * @param SSL pop3 support encryption?
        public void connectToServer(String uname,String mailServer,String mailuname,
                String mailPwd,String port,String SSL){
            serverConn=mailServer+":"+mailuname;
            try {
                if(SSL.equalsIgnoreCase("true")){
                    Properties props = System.getProperties();
                    props.setProperty( "mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
                    props.setProperty( "mail.pop3.socketFactory.fallback", "false");
                    props.setProperty("mail.pop3.port", port);
                    props.setProperty("mail.pop3.socketFactory.port", port);
                    Session session = Session.getInstance(props);
                    store = session.getStore("pop3");
                }else{
                    props=new Properties();
                    props = System.getProperties();
                    // Get a Session object
                    session = Session.getInstance(props, null);
                    store = session.getStore("imap");
                // session.setDebug(true);
                // Get a Store object
                // Connect
                store.connect(mailServer, mailuname, mailPwd);
                // Open a Folder
                folder = store.getFolder("INBOX");
                System.out.println("Opening the inbox folder for " + mailServer);
                if (folder == null || !folder.exists()) {
                    //Tray.showBallon("Warning","Invalid folder Name:"+folder.getName(),Tray.WARNING);
                    System.exit(1);
                folder.open(Folder.READ_WRITE);
                // Add messageCountListener to listen for new messages
                folder.addMessageCountListener(new MessageCountAdapter() {
                    public void messagesAdded(MessageCountEvent ev) {
                        System.out.println("new mail " + serverConn);
                        readMail(ev);
                // Check mail once in "freq" MILLIseconds
            } catch (Exception ex) {
                ex.printStackTrace();
         * Listen for incoming messages
        public void run(){
            try {
                while(serverStatus){
                    // sleep for freq milliseconds
                    // This is to force the IMAP server to send us
                    // EXISTS notifications.
                    System.out.println("Reading for change for " + serverConn);
                    folder.getMessageCount();
                    Thread.sleep(freq);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            } catch (MessagingException ex) {
                ex.printStackTrace();
         * This method is triggered upon receival of the message
         * @param ev Message Object event
        public void readMail(MessageCountEvent ev){
            Message[] msgs = ev.getMessages();
            String from="";
            String subject="";
            String body="";
            status="New Mail";
            // Message retrival part
            for (int i = 0; i < msgs.length; i++) { // for each new entry
                try {
                    from=((InternetAddress)msgs.getFrom()[0]).getPersonal(); //get From whom the came from
    if (from==null)
    from=((InternetAddress)msgs[i].getFrom()[0]).getAddress();
    subject=msgs[i].getSubject(); //get the subject of the message
    //check message if it contain other parts, such as attachment
    Part messagePart = msgs[i];
    Object content=messagePart.getContent();
    if (content instanceof Multipart){
    messagePart=((Multipart)content).getBodyPart(0);
    // -- Get the content type --
    String contentType=messagePart.getContentType();
    //this the mail is plain mail.. or contain some html
    if (contentType.startsWith("text/plain")|| contentType.startsWith("text/html")){
    //get the mail
    BufferedReader reader=new BufferedReader(new InputStreamReader(messagePart.getInputStream()));
    //start reading line after line
    String b=reader.readLine();
    while (b!=null){
    b=reader.readLine();
    body+=b + "\n";
    writingLogs(from + ":" + ((InternetAddress)msgs[i].getFrom()[0]).getAddress(),subject,body);
    checkMsg(((InternetAddress)msgs[i].getFrom()[0]).getAddress(),subject,body);
    msgs[i].setFlag(Flags.Flag.DELETED, true); //delete the messages
    reader.close();
    } catch (IOException ioex) {
    ioex.printStackTrace();
    } catch (MessagingException mex) {
    mex.printStackTrace();
    * This method is used to write the mail to the log, so as to keep track
    * of all the incoming messages...
    * @param strFrom from where the mail is originated
    * @param strSubject the subject of the message
    * @param strBody the body of the message
    public void writingLogs(String strFrom,String strSubject,String strBody ){
    Date today = new Date();
    DateFormatSymbols symbols;
    SimpleDateFormat formatter;
    symbols = new DateFormatSymbols(new Locale("en","US"));
    formatter = new SimpleDateFormat("yyyyMMddHHmmss", symbols);
    String result = formatter.format(today);
    BufferedWriter bw;
    try {
    String path=new File(".").getCanonicalPath();
    bw = new BufferedWriter(new FileWriter(path+"\\logs\\"+result + ".txt"));
    bw.write("From..." + strFrom +"\n");
    bw.write("---------------------------------------------------------\n");
    bw.write("Subject..."+strSubject+"\n");
    bw.write("---------------------------------------------------------\n");
    bw.write("Body..."+strBody+"\n");
    bw.flush();
    bw.close();
    } catch (IOException ex) {
    ex.printStackTrace();
    public void checkMsg(String from,String subject,String body){
    String msg="";
    ResultSet rsP=db.executeQuery("SELECT * " +
    "FROM priority " +
    "WHERE uname='" + uname + "'");
    try {
    boolean fReading=true;
    int i=1;
    rsP.first();
    while(fReading){
    int p=checkPriority(rsP.getString("Priority"+(i++)));
    if(i>3) {fReading=false;break;}
    switch(p){
    case 1:
    msg=readFrom(from,body);break;
    case 2:
    msg=readSubject(from,subject,body);break;
    case 3:
    msg=readBody(from,body);break;
    case -1:
    fReading=false;break;
    } catch (SQLException ex) {
    ex.printStackTrace();
    public int checkPriority(String p){
    if (p.equalsIgnoreCase("From")){
    return 1;
    }else if(p.equalsIgnoreCase("Subject")){
    return 2;
    }else if(p.equalsIgnoreCase("Body")){
    return 3;
    return -1;
    private String readBody(String from, String body) {
    return null;
    private String readSubject(String from, String subject, String body) {
    return null;
    private String readFrom(String from, String body) {
    boolean Matched=false;
    String s=from.substring(0,from.indexOf("@"));
    ResultSet rsR=db.executeQuery("SELECT * " +
    "FROM Rules " +
    "WHERE [if]='from' and uname='" + uname + "'");
    try {
    rsR.first();
    do{
    Matched=checkPattern(from,rsR.getString("Contains"));
    if(Matched){
    break;
    }while(rsR.next());
    MailSender m=new MailSender();
    m.send(rsA.getString("smtpmailuname"),
    rsA.getString("smtpmailuname"),
    rsA.getString("smtpserver"),
    rsA.getString("smtpport"),
    rsA.getString("smtpmailuname"),
    rsR.getString("phoneNo"),
    "Server Message",
    body
    } catch (SQLException ex) {
    ex.printStackTrace();
    return null;
    public boolean checkPattern(String original, String contains){
    if(contains.indexOf(original)>0){
    return true;
    return false;
    Let me explain... just consider connectToServer
    there is SSL.equalsIgnoreCase("true") which is google.. this is what you want in this if statement... it configure the properties of google... try it..

Maybe you are looking for

  • Button's Destination URI is not working

    Hi, I have a requirement to keep a button(View Invoice) on a custom notification page. Whenever the button is clicked, it needs to open a new page(not OA.jsp) to show the invoice image. I used Item Style as Button and in the controller, setDestinatio

  • IMix ratings all screwed up

    Hey there. When I try to rate iMixes the wrong rating shows up... For example, I give an iMix 5 stars and when it registers in the system it gives it 1 star. I know it's truly taking the lower rating as the total stars from the iMix will suddenly dro

  • ABAP needed: New Value/Old Value in Update Rules

    Hi all I'm updating some attributes in IObj by ABAP routine. Is it possible to get not only new value of attribute but the old one to compare them? Is it possible to get others attribute old and new values? I'll illustrate it with example. Say, IObj

  • 3D: how to move a mesh using JS

    Hi! how to move a mesh using JS in 3d-model (for example, I need to move by 5 pixels in X, Y, Z). Thank you :)

  • How do i get rid of firefox.exe bad image

    that is all the information i can give.