Dashboard > Mule FAQ - Open Source ESB and Integration Platform > ... > Frequently Asked Questions (FAQ) > Troubleshooting ErrorHandler example mailing problem - java.net.ConnectException
  Mule FAQ - Open Source ESB and Integration Platform Log In | Sign Up   View a printable version of the current page.  
  Troubleshooting ErrorHandler example mailing problem - java.net.ConnectException

Added by Kristanto Chan , last edited by Kristanto Chan on Jul 31, 2007
Labels: 

Troubleshooting ErrorHandler example mailing problem - java.net.ConnectException

In Mule1.4.1, the errorhandler example to mail FatalException XML doesn't work by default. Below is the exception when one tries to mail the XML:

********************************************************************************
Message               : Unable to connect to mail transport.
Type                  : org.mule.umo.endpoint.EndpointException
Code                  : MULE_ERROR-59999
JavaDoc               : http://mule.mulesource.org/docs/apidocs/org/mule/umo/endpoint/EndpointException.html
********************************************************************************
Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
  java.net.PlainSocketImpl:-2 (http://java.sun.com/j2se/1.4.2/docs/api/java/net/ConnectException.html)
2. Could not connect to SMTP host: localhost, port: 25 (javax.mail.MessagingException)
  com.sun.mail.smtp.SMTPTransport:1282 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/mail/MessagingException.html)
3. Unable to connect to mail transport. (org.mule.umo.endpoint.EndpointException)
  org.mule.providers.email.SmtpMessageDispatcher:60 (http://mule.mulesource.org/docs/apidocs/org/mule/umo/endpoint/EndpointException.html)
********************************************************************************
Root Exception stack trace:
java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)

The getHost method in SmtpConnector (declared in email.properties) is never used for emailing. Whenever an smtp host is required, it is always retrieved from the host possessed by an EndPoint (host in UMOEndpointURI). By default, this value is never set and always refers to localhost.

Solution alternative

We need to declare the smtp host in the mule-config.xml. Below is a snippet of the XML used for mailing:

<endpoint address="smtp://mail.mySMTP.com.au?address=${email.toAddress}" transformers="ErrorMessageToExceptionBean ExceptionBeanToXML StringToEmailMessage">
      <properties>
         <property name="fromAddress" value="${email.fromAddress}" />
         <property name="subject" value="${email.subject}" />
         <property name="replyToAddresses" value=""/>
      </properties>
</endpoint>
Copyright(c) CustomWare Asia Pacific Pty Ltd
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators