Date Created: Tue 27-Nov-2007

Related Document Categories:



    When trying to send an SMTP message using the JavaMail API you get the following error:

    Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect


    Solution:


    The server you are using as an SMTP relay has security settings that deny the host you are sending from relaying SMTP through the server specified by the javax.mail properties in your class or session properties set on your WebLogic or WebSphere server.


    or


    Ensure your code specifies the 'From' field in the Java Class as often certain SMTP server will try to look up the senders email address in DNS or will discard of there is no 'From' details in the SMTP header etc.


    or


    in WebLogic you can set the Servers - Mail - Configuration to set global mail session properties.



Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Oracle WebLogic Categories

JBoss Categories

Other Categories