3

I'm trying to send and email using my gmail address. I set debug to true and this is what I get.

DEBUG: JavaMail version 1.4.1
DEBUG: not loading file: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javamail.providers
DEBUG: java.io.FileNotFoundException: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javamail.providers (No such file or directory)
DEBUG: !anyLoaded
DEBUG: not loading resource: /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.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,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: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, 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: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: not loading file: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javamail.address.map
DEBUG: java.io.FileNotFoundException: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javamail.address.map (No such file or directory)

DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL true

And then I does just nothing, no error/warning/....

I'm using these settings :

mail.smtp.auth=true
mail.debug=true
mail.smtp.host=smtp.gmail.com
mail.smtp.user=MyOwnUserName@gmail.com
mail.smtp.password=MyOwnPassword
mail.transport.protocol=smtp
mail.smtp.port=465
mail.disable=false
mail.verbose=true
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory

I tried these examples :

  1. http://adfblogs.blogspot.be/2012/01/sending-e-mail-from-adf-application.html
  2. Send email using java

All the same problem. And I'm 100% sure my password and emailadress is correct.

Edit: My code (the same as in the first link) nitialContext ic = new InitialContext(); Session session = (Session) ic.lookup("mail/SugarCRMMailSession");

        Properties props = session.getProperties();

        String  to = emailID;

        String mailhost = props.getProperty("mail.smtp.host");
        String user = props.getProperty("mail.smtp.user");
        String password = props.getProperty("mail.smtp.password");
        String protocol = props.getProperty("mail.transport.protocol");

        String authorization = props.getProperty("mail.smtp.auth");
        String mailDisabled = props.getProperty("mail.disable");
        String verboseProp = props.getProperty("mail.verbose");
        String debugProp = props.getProperty("mail.debug");

        boolean sentDisabled = false;
        if(mailDisabled.equals("true"))
            sentDisabled = true;

        if(!sentDisabled){

            boolean auth = false;
            if(authorization.equals("true"))
                auth = true;

            boolean verbose = false;
            if(verboseProp.equals("true"))
                verbose = true;

            String mailer = "smtpsend";

            if(debugProp.equals("true"))
                session.setDebug(true);
            else
                session.setDebug(false);

            Message msg = new MimeMessage(session);
            msg.setFrom();      
            msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
            msg.setSubject(subject);
            msg.setContent(text, "text/html;charset=UTF-8");      
            msg.setHeader("X-Mailer", mailer);
            msg.setSentDate(new Date());

            SMTPTransport t = (SMTPTransport)session.getTransport(protocol);

            try {
                t.connect(mailhost, user, password);
                t.sendMessage(msg, msg.getAllRecipients());
            } finally {
                    t.close();
            }

             System.out.println("\nMail was sent successfully.");
        }else{
             System.out.println("Mail Sending is disabled.");
        }
Community
  • 1
  • 1
User404
  • 2,152
  • 2
  • 27
  • 35

1 Answers1

0

Here this is perfect solution for your problem download Mail api jar form here

Api mail providers for gmail

and just go to Windows --> Preferencs --> Java --> Installed JRES -->

and what ever JRE You are using just select it and EDIT and then add that external jar into that JRE and Click okey then Compiler will able to load that jar file. hence the error will get resolved.

Try it.

Kishan Bheemajiyani
  • 3,429
  • 5
  • 34
  • 68
  • Thanks for your reply. The problem I faced was with SSL in our network. Fyi I used javamail on a WebLogic Server. – User404 Jan 02 '14 at 09:36
  • But have u got solution for that? what is the real solution for that but ya this solution is worked for me. have u tried.? – Kishan Bheemajiyani Jan 02 '14 at 10:46
  • Yes, our network administrator modified our firewall if I'm not mistaking. – User404 Jan 02 '14 at 13:47
  • okey so there is problem with that. and which port u are working in for this? – Kishan Bheemajiyani Jan 03 '14 at 06:51
  • May be if u try with Port 25 then there wont be need of changing firewall settings. i think so because same issue i was facing and i got that solution with out changing firewall. – Kishan Bheemajiyani Jan 03 '14 at 06:59
  • Link doesn't exist anymore – Andrei Suvorkov Oct 09 '18 at 08:19
  • Link is dead, but downloading *.jars is an old style of getting deps. Consider using Apache ivy, or gradle, for lib jar dependancies, and then use the maven repository online to find the code to download them. – Jonathan Dec 05 '18 at 00:37
  • for those who have ssl issue with such cases I have tried the github repo [link](https://github.com/escline/InstallCert) detailed usage can be seen on the readme of the repo. It will basically retrieve the certificate from the the host:port you are trying to reach and add it to your jvm/jre certificate path. – Olgun Kaya May 06 '20 at 05:34