• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Prob with connecting SMTP on port 25

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ranchers,

I am developing a client application which can send and recieve mails from ISP. The recieving part works fine .I m able to connect to the POP server and able to fetch the mail. But i could not able to send the mail. It gives teh forllowing exception:! Any thoughts about wat went wrong

Exception:---->>>>


<Oct 31, 2006 12:01:28 PM GMT+05:30> <Warning> <HTTP> <BEA-101248> <[null]: Depl
oyment descriptor "web.xml" is malformed. Check against the DTD: org.xml.sax.SAX
ParseException: cvc-elt.1: Cannot find the declaration of element 'web-app'. (line 2, column 10).>
DEBUG: not loading system providers in <java.home>/lib
DEBUG: not loading optional custom providers file: /META-INF/javamail.providers
DEBUG: successfully loaded default providers

DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPTransport=javax.ma
il.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,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.Provide
r[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imap=javax.mail.Provider[STORE,imap,com.su
n.mail.imap.IMAPStore,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop
3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], smtp=javax.mail.Provider[T
RANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: not loading optional address map file: /META-INF/javamail.address.map

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true

DEBUG: SMTPTransport trying to connect to host "smtp.ktk.airtelbroadband.in", port 25

javax.mail.MessagingException: Could not connect to SMTP host: smtp.ktk.airtelbr
oadband.in, port: 25;
nested exception is:
java.net.SocketException: Software caused connection abort: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:867)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:15
6)
at javax.mail.Service.connect(Service.java:234)
at javax.mail.Service.connect(Service.java:135)
at mail.sendMessage(mail.java:79)
at mail.doPost(mail.java:36)
at mail.doGet(mail.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)



The Code as follows--------------->>>>>>

import javax.mail.*;
import javax.mail.internet.*;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;

import javax.servlet.*;
import javax.servlet.http.*;

import javax.mail.Transport;

public class mail extends HttpServlet{


private final static String DEFAULT_SERVER="smtp.ktk.airtelbroadband.in";

public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{

String smtpServ="smtp.ktk.airtelbroadband.in";
String from= "";
String to= "";
String subject="subject1";
String emailContent="This is a Test Email";




response.setContentType("multipart/alternative");
java.io.PrintWriter out = response.getWriter();

out.println("<html><head><title>Email MEssage sender</title></head></html>");

try{
sendMessage(smtpServ, to, from, subject, emailContent,out);}


catch(Exception e)
{
throw new ServletException(e.getMessage());
}
out.println("<h2>The Message was sent successfully</h2>");
out.println("</body></html>");
}

private void sendMessage(String smtpServ,String to,String from,String subject,String emailContent,PrintWriter out) throws Exception
{


try{
Properties properties=System.getProperties();

properties.put("mail.smtp.host",smtpServ);
properties.put("mail.smtp.auth", "true");
properties.put("mail.debug", "true");

Session session=Session.getDefaultInstance(properties);

Message mailMsg=new MimeMessage(session);

Multipart mp = new MimeMultipart();

BodyPart b1 = new MimeBodyPart();
b1.setContent("hi","text/plain");

mp.addBodyPart(b1);

mailMsg.setContent(mp);

mailMsg.saveChanges();

Transport bus = session.getTransport("smtp");
bus.connect("smtp.ktk.airtelbroadband.in","yyyy","zzz");
out.println("connected");
bus.send(mailMsg);
out.println("Message sent");
}
catch(MessagingException ex)
{
ex.printStackTrace();

}
}

public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{

doPost(request,response);
}
}


Thanks...

TUHIN
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may not have anything to do with the problem, but how are you setting username and password?

Can you connect to the host directly by typing "telnet smtp.ktk.airtelbroadband.in 25" on the command line?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Software caused connection abort: connect


I'd check there are no firewalls or port blocking software between you and your server.
 
Tuhin Ghosh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ulf and paul,

i did check the telnet smtp.ktk.airtelbroadband.in . Its aborting connection.
Is this an Issue? Coz am successfuly fetching the mail from the same server using POP.

so any other thing that i missed...? which is important.Please tell me.

Thanks
TUHIN
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is. If you can't connect via SMTP, you can't use JavaMail (as it is) to send emails.

This sounds like a configuration thing. I wouldn't be suprised if your server admin has stopped anything connecting to his server to send mails, but is happy to allow a connection to retreive them. Speak to him/her/them.
 
Tuhin Ghosh
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
k one more thing i successfully connected using Outlook. on port 25 with same SMTP name. Guide me !!!



Thanks

TUHIN
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<Oct 31, 2006 12:01:28 PM GMT+05:30> <Warning> <HTTP> <BEA-101248> <[null]: Depl
oyment descriptor "web.xml" is malformed. Check against the DTD: org.xml.sax.SAX
ParseException: cvc-elt.1: Cannot find the declaration of element 'web-app'. (line 2, column 10).>


There seems to be something seriously wrong with the deployment descriptor of your web application. The error message suggests you don't have a 'web-app' element in there. Check your deployment descriptor and make sure it is correct.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tuhin Ghosh:
Hi,
k one more thing i successfully connected using Outlook. on port 25 with same SMTP name. Guide me !!!



Thanks

TUHIN



Did you? Out the box Outlook uses MAPI to connect to Exchange - so if you configured a new Microsoft Exchange Server in your Outlook services you are probably connecting via MAPI, not SMTP.

Or it is possible that you have port blocking software stopping applications other than recognized MUAs connecting to the server. Check that.

Still this still sounds like the sort of configuration issue that can be solved easily by speaking to the person in charge of the SMTP server you are trying to connect to.
 
reply
    Bookmark Topic Watch Topic
  • New Topic