Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » SMTP Permission denied: connect error when using Eclipse(Email can't be sent when using Eclipse but works on executable jar)
SMTP Permission denied: connect error when using Eclipse [message #1785164] Tue, 10 April 2018 08:06 Go to next message
GTO Support is currently offline GTO SupportFriend
Messages: 2
Registered: April 2018
Junior Member
The code below does not work on Eclipse however exporting to runnable jar works. It also works on another non-Eclipse IDE. Please advise what else can I look at?


My environment:
Eclipse Java EE IDE for Web Developers.
Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500
Java 1.8
email library: javax.mail.jar

This is my code snippet:

        Properties mailProperties = new Properties();
        mailProperties.put("mail.smtp.host", "smtp.company.com");

        Session session = Session.getInstance(mailProperties, null);

        try {
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom("me@company.com");
            msg.setRecipients(Message.RecipientType.TO, "user@company.com");
            msg.setSubject("Test mail");
            msg.setText("If you got this, mail is working");
            Transport.send(msg);
        }catch (MessagingException mex){
            System.out.println("Send mail failed");
            mex.printStackTrace(System.out);
            return;
        }

        System.out.println("Mail test complete");


Stacktrace:
Send mail failed
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.company.com, 25; timeout -1;
nested exception is:
java.net.SocketException: Permission denied: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.Service.connect(Service.java:366)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at com.gemalto.test.Main.main(Main.java:29)
Caused by: java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:353)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:239)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2175)
... 7 more
Re: SMTP Permission denied: connect error when using Eclipse [message #1785220 is a reply to message #1785164] Wed, 11 April 2018 07:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29653
Registered: July 2009
Senior Member
This forum is for asking questions about how to use JDT. It's not a general Java programming forum. Try something like stackoverflow for that purpose.
Re: SMTP Permission denied: connect error when using Eclipse [message #1785649 is a reply to message #1785220] Wed, 18 April 2018 02:41 Go to previous message
GTO Support is currently offline GTO SupportFriend
Messages: 2
Registered: April 2018
Junior Member
The question is Eclipse specific because the issue only happens in Eclipse.
Previous Topic:problem when updating eclipse
Next Topic:Help About an Applet
Goto Forum:
  


Current Time: Thu Nov 15 07:56:15 GMT 2018

Powered by FUDForum. Page generated in 0.02481 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top