java - Could not connect to SMTP host Permission denied: connect -


the email working in windows server 2008, when changed windows server 2012, causing error.

systemexception: javax.mail.messagingexception: not connect smtp host: smtp.sendgrid.net, port: 25; nested exception is: java.net.socketexception: permission denied: connect  

i have googled , told -djava.net.preferipv4stack=true, put entry in jvm system property , asked disabled antivirus. both didn't worked. tried contacting isp open 25 port , 25 port listening. code.

    properties props = new properties();     props.put("mail.transport.protocol", "smtp");     props.put("mail.smtp.host", smtp_host_name);     props.put("mail.smtp.port", 25);     props.put("mail.smtp.auth", "true");     smtpauthenticator auth = new smtpauthenticator();     session mailsession = session.getdefaultinstance(props, auth);     mailsession.setdebug(true);     transport transport = mailsession.gettransport();     mimemessage message = new mimemessage(mailsession);     //read template , replace values using velocity engine     string text = messagecontent;     message.setfrom(new internetaddress(from));     message.setsubject(subject);     transport.connect();     transport.sendmessage(message, message.getrecipients(message.recipienttype.to));     transport.close(); 

i using sendgrid, java8, struts 2 , apache tomcat 8.you last hope, please me that. in advance.

i having similar type of error this, , code working fine me plus disable antivirus software system cause problem. hope works you.

properties props = new properties(); props.put("mail.smtp.host", "smtp.gmail.com");  // smtp host props.put("mail.smtp.port", "587");  // tls port 25/587 props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true");  // enable authentication 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -