I am trying to write add sending an email to an application I have written in java, I found a good guide. http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/
But how do I add the javaee.jar
and mail.jar
dependencies?
I added the dependencies but I get
"Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.SocketException: Unrecognized Windows Sockets error: 87: create at sendMail.main(sendMail.java:47) Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.SocketException: Unrecognized Windows Sockets error: 87: create at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654) at javax.mail.Service.connect(Service.java:317) at javax.mail.Service.connect(Service.java:176) at javax.mail.Service.connect(Service.java:125) at javax.mail.Transport.send0(Transport.java:194) at javax.mail.Transport.send(Transport.java:124) at sendMail.main(sendMail.java:42) Caused by: java.net.SocketException: Unrecognized Windows Sockets error: 87: create at java.net.Socket.createImpl(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:321) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927) ... 7 more "
Any ideas what is wrong?