Problem in sending mails through SMTP

J

Jagdeesh

Hi everyone,

I am new for this SMTP Server. I need to send a confirmation mail from
using JSP..but when i run the application i get these exceptions..can
anyone tell me whats the reason for these exceptions.


[java] javax.mail.SendFailedException: Sending failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused: connect
[java] at javax.mail.Transport.send0(Transport.java:219)
[java] at javax.mail.Transport.send(Transport.java:81)
[java] at com.sun.ebxml.soapmsh.SMTPConnection.send(SMTPConnection.java
:157)
[java] at org.apache.soap.messaging.Message.send(Message.java:123)
[java] at com.sun.ebxml.soapmsh.SOAPMessageImpl.send(SOAPMessageImpl.ja
va:331)
[java] at com.laura.customers.mbis.send(mbis.java:196)
[java] at com.laura.customers.mbis.confirmOrder(mbis.java:165)
[java] at actions._0002factions_0002fconfirm_0005fsend_0002ejspconfirm_
0005fsend_jsp_0._jspService(_0002factions_0002fconfirm_0005fsend_0002ejspconfirm
_0005fsend_jsp_0.java:192)
[java] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.jav
a:119)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.jasper.servlet.JspServlet$JspServletWrapper.servic
e(JspServlet.java:177)
[java] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServle
t.java:318)
[java] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
391)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.tomcat.core.ServletWrapper.doService(ServletWrappe
r.java:404)
[java] at org.apache.tomcat.core.Handler.service(Handler.java:286)
[java] at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.
java:372)
[java] at org.apache.tomcat.core.ContextManager.internalService(Context
Manager.java:797)
[java] at org.apache.tomcat.core.ContextManager.service(ContextManager.
java:743)
[java] at org.apache.tomcat.service.http.HttpConnectionHandler.processC
onnection(HttpConnectionHandler.java:210)
[java] at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoi
nt.java:416)
[java] at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadP
ool.java:498)
[java] at java.lang.Thread.run(Thread.java:534)
[java] SOAPMessageImpl ERROR: Sending failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused: connect
[java] Exception is: [SOAPException:
faultCode=SOAP-ENV:Client; msg=Se
nding failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused:
connect; targetEx
ception=javax.mail.SendFailedException: Sending failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused:
connect]
[java] at com.sun.ebxml.soapmsh.SMTPConnection.send(SMTPConnection.java
:160)
[java] at org.apache.soap.messaging.Message.send(Message.java:123)
[java] at com.sun.ebxml.soapmsh.SOAPMessageImpl.send(SOAPMessageImpl.ja
va:331)
[java] at com.laura.customers.mbis.send(mbis.java:196)
[java] at com.laura.customers.mbis.confirmOrder(mbis.java:165)
[java] at actions._0002factions_0002fconfirm_0005fsend_0002ejspconfirm_
0005fsend_jsp_0._jspService(_0002factions_0002fconfirm_0005fsend_0002ejspconfirm
_0005fsend_jsp_0.java:192)
[java] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.jav
a:119)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.jasper.servlet.JspServlet$JspServletWrapper.servic
e(JspServlet.java:177)
[java] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServle
t.java:318)
[java] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
391)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.tomcat.core.ServletWrapper.doService(ServletWrappe
r.java:404)
[java] at org.apache.tomcat.core.Handler.service(Handler.java:286)
[java] at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.
java:372)
[java] at org.apache.tomcat.core.ContextManager.internalService(Context
Manager.java:797)
[java] at org.apache.tomcat.core.ContextManager.service(ContextManager.
java:743)
[java] at org.apache.tomcat.service.http.HttpConnectionHandler.processC
onnection(HttpConnectionHandler.java:210)
[java] at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoi
nt.java:416)
[java] at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadP
ool.java:498)
[java] at java.lang.Thread.run(Thread.java:534)



My Java file for com.laura.customers.mbis.send and
com.laura.customers.mbis.confirmorder is as follows:

public SOAPMessageImpl confirmOrder(SOAPMessageImpl request,
byte[] payload)
throws SOAPException {
if (state != mbis.ORDERMESSAGE_RECD)
throw new SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT,
"Choreography error: ");
String service = ORDERSERVICE;
String action = CONFIRMACTION;
String refmsgid = request.getProperty(com.sun.ebxml.soapmsh.Constants.MSGID);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamResult res = new StreamResult(baos);
Hashtable params = new Hashtable();
params.put("ConversationId", request.getProperty("convid"));
try {
transform(new ByteArrayInputStream(payload), res, confXsl, params);
}
catch (TransformerException x) {
x.printStackTrace(System.err);
throw new SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT,
"unable to transform confirmation!");
}
SOAPMessageImpl msg = send(service, action, refmsgid,
"confirm.xml", payload, "confirm.html", baos.toByteArray());
setState(mbis.SUCCESS);
return msg;
}

protected SOAPMessageImpl send(String service,
String action, String refmsgid, String loc, byte[]
payload,
String loc2, byte[] payload2)
throws SOAPException {
try {
byte [] payloadBytes = Utils.prettyPrint(payload);

InternetHeaders hdrs = new InternetHeaders();
hdrs.addHeader("Content-Type", "application/xml");
hdrs.addHeader("Content-Location", loc);
String _cid = MimeUtils.getUniqueValue();
String cid = '<' + _cid + '>';
hdrs.addHeader("Content-ID", cid);
MimeBodyPart payloadPart = new MimeBodyPart(hdrs,
payloadBytes);
SOAPMessageImpl msg = createMessage(service, action,
refmsgid, _cid);
msg.addBodyPart(payloadPart);

InternetHeaders hdrs2 = new InternetHeaders();
hdrs2.addHeader("Content-Type", "text/html");
hdrs2.addHeader("Content-Location", loc2);
String cid2 = '<' + MimeUtils.getUniqueValue() + '>';
hdrs2.addHeader("Content-ID", cid2);
payloadPart = new MimeBodyPart(hdrs2, payload2);
msg.addBodyPart(payloadPart);
msg.send();
return msg;
}
catch (Exception x) {
x.printStackTrace();
throw new
SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT,
x.getMessage(), x);
}
}

I am waiting for a hint to locate my error. Thanx in advance.

regads,
Jagdeesh
 
G

GaryM

(e-mail address removed) (Jagdeesh) wrote in
Hi everyone,

I am new for this SMTP Server. I need to send a confirmation mail
from using JSP..but when i run the application i get these
exceptions..can anyone tell me whats the reason for these
exceptions.

Javamail requires you to define an SMTP host as part of its properties.
Absent this, it assumes that the localhost has an SMTP server running.
In this case you do not (3rd line down). So you need the address of an
SMTP server and tell Javamail of it, or you need to run one on your
localhost (a risky endeavor and not to done without absolute surity you
are not creating an open relay for spammers to exploit).

See the the package documentation for the Javamail API for further
information on the properties.

Gary
 
M

MacTotoche

Jagdeesh said:
Hi everyone,

I am new for this SMTP Server. I need to send a confirmation mail from
using JSP..but when i run the application i get these exceptions..can
anyone tell me whats the reason for these exceptions.
Hello,
the problem seems to be in the first lines :
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused

Are you sure you have a correctly installed, configured, running, mail
agent (like sendmail) on localhost, if this is the host you want to
use to send the mail ?
 
S

Sudsy

Jagdeesh wrote:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: localhost, port: 25;
I am waiting for a hint to locate my error. Thanx in advance.

The exception tells you everything you need to know. The application
is trying to connect to the SMTP daemon at the "well-known port" (25)
on the localhost. You apparently don't have the daemon running.
Without additional configuration information (O/S, program launcher,
etc.) then it's not possible to tell you how to proceed.
 
T

Tim Tyler

: Hi everyone,

: I am new for this SMTP Server.

[...]

: regads,
: Jagdeesh

This post shows signs of being sent from my Google Groups account.
It may be a mix up by Google - or I may need to change my password.
 
G

Gordon Beaton

: Hi everyone,

: I am new for this SMTP Server.

[...]

: regads,
: Jagdeesh

This post shows signs of being sent from my Google Groups account.
It may be a mix up by Google - or I may need to change my password.

I'm curious to know what signs you mean, since I can't see that he
claims to be Tim Tyler. AFAICT, yours is the only post in this thread
that appears (to me anyway) to come from you.

The post you've replied to has these headers:

From: (e-mail address removed) (Jagdeesh)
Newsgroups: comp.lang.java.programmer
Subject: Problem in sending mails through SMTP
Date: 8 Aug 2003 03:55:32 -0700
Organization: http://groups.google.com/
Lines: 189
Message-ID: <[email protected]>
NNTP-Posting-Host: 141.44.242.67
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1060340133 25653 127.0.0.1 (8 Aug 2003 10:55:33 GMT)
X-Complaints-To: (e-mail address removed)
NNTP-Posting-Date: 8 Aug 2003 10:55:33 GMT

Except for the NNTP-Posting-Host (is it your IP?), most of these are
pretty generic.

/gordon
 
R

Roedy Green

SMTP host: l
ocalhost, port: 25;
I suggest firing up Eudora or some similar mail program and see if
you can send mail to your local host mailserver.

I suspect you don't have a localHost mail server. Instead you have to
configure JavaMail to use your ISP mail server, likely with
login/password. Get it working with Eudora, and then note the eudora
settings that work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top