Problem while sending mail using commons email

View: New views
3 Messages — Rating Filter:   Alert me  

Problem while sending mail using commons email

by Pavan Kumar-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I wrote a custom binding component to send email notifications which used
commons email. The problem is that the code in the component tries to
connect to the "localhost" even though the mail server IP is given and
finally end in a SocketException. The same exact piece of code with out any
changes works if I run it as a standalone java program.

I did some googling and tried options like using the hostname instead of
IPaddress etc, but no use. The connectivity between the system I run this
app and the mail server is also good.

I have set the debug on for the commons-email classes and the trace is as
below

I use the following software
    apache-servicemix-3.0-incubating
    commons-email-1.1

*Standalone java program
----------------------------------------*
DEBUG: JavaMail version 1.3.1
DEBUG: java.io.FileNotFoundException:
D:\Installations\JavaIDEs\MyEclipse\MyEclipse_5.5.1_GA\jre\lib\javamail.providers
(The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name:
{com.sun.mail.smtp.SMTPTransport=javax.mail.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.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc]}
DEBUG: Providers Listed By Protocol:
{imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
Microsystems, Inc],
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
Microsystems, Inc],
smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException:
D:\Installations\JavaIDEs\MyEclipse\MyEclipse_5.5.1_GA\jre\lib\javamail.address.map
(The system cannot find the file specified)
DEBUG: getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host *"10.193.50.60", port 25*  <<
Connected correctly and mail is sent nicely

220 bgxius-ex01.XIUS-bcgi.ltd Microsoft ESMTP MAIL Service ready at Wed, 6
May 2009 12:50:09 +0530
DEBUG SMTP: connected to host "10.193.50.60", port: 25

*Same code from within the binding component
*
-----------------------------------------------------------------------------
Loading javamail.default.providers from
jar:file:/D:/Installations/J2EE/Servers/ServiceMix/apache-servicemix-3.0-incubating/bin/../lib/optional/mail.jar!/META-INF/javamail.default.providers
DEBUG: loading new provider protocol=imap,
className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc,
version=null
DEBUG: loading new provider protocol=smtp,
className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc,
version=null
DEBUG: loading new provider protocol=pop3,
className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc,
version=null
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@12be8e1;
class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@12be8e1;
class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@12be8e1;
class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@12be8e1;
class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@12be8e1;
class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG: getProvider() returning provider protocol=smtp;
type=javax.mail.Provider$Type@12be8e1;
class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host *"localhost", port 25*  << tries to
connect localhost & results in exception

DEBUG SMTP: exception reading response:* java.net.SocketException:
Connection reset*
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "localhost", port 25

DEBUG SMTP: exception reading response: java.net.SocketException: Connection
reset
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "localhost", port 25


Any help would be appreciated.


Thanks & Reagrds
Pavan

Re: Problem while sending mail using commons email

by Madhavi Kumar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

kinda tent vesi ,
suzana aunty& whole family
vissu,shashi
radhivallu,manju
mahesh,purustam
pakanti vallu,2 familes
On Wed, May 6, 2009 at 2:09 PM, Pavan Kumar <pavan.technology@...>wrote:

> Hi,
>
> I wrote a custom binding component to send email notifications which used
> commons email. The problem is that the code in the component tries to
> connect to the "localhost" even though the mail server IP is given and
> finally end in a SocketException. The same exact piece of code with out any
> changes works if I run it as a standalone java program.
>
> I did some googling and tried options like using the hostname instead of
> IPaddress etc, but no use. The connectivity between the system I run this
> app and the mail server is also good.
>
> I have set the debug on for the commons-email classes and the trace is as
> below
>
> I use the following software
>    apache-servicemix-3.0-incubating
>    commons-email-1.1
>
> *Standalone java program
> ----------------------------------------*
> DEBUG: JavaMail version 1.3.1
> DEBUG: java.io.FileNotFoundException:
>
> D:\Installations\JavaIDEs\MyEclipse\MyEclipse_5.5.1_GA\jre\lib\javamail.providers
> (The system cannot find the file specified)
> DEBUG: !anyLoaded
> DEBUG: not loading resource: /META-INF/javamail.providers
> DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
> DEBUG: Tables of loaded providers
> DEBUG: Providers Listed By Class Name:
>
> {com.sun.mail.smtp.SMTPTransport=javax.mail.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.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
> Microsystems, Inc]}
> DEBUG: Providers Listed By Protocol:
> {imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
> Microsystems, Inc],
> pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
> Microsystems, Inc],
> smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]}
> DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
> DEBUG: !anyLoaded
> DEBUG: not loading resource: /META-INF/javamail.address.map
> DEBUG: java.io.FileNotFoundException:
>
> D:\Installations\JavaIDEs\MyEclipse\MyEclipse_5.5.1_GA\jre\lib\javamail.address.map
> (The system cannot find the file specified)
> DEBUG: getProvider() returning
> javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: trying to connect to host *"10.193.50.60", port 25*  <<
> Connected correctly and mail is sent nicely
>
> 220 bgxius-ex01.XIUS-bcgi.ltd Microsoft ESMTP MAIL Service ready at Wed, 6
> May 2009 12:50:09 +0530
> DEBUG SMTP: connected to host "10.193.50.60", port: 25
>
> *Same code from within the binding component
> *
>
> -----------------------------------------------------------------------------
> Loading javamail.default.providers from
>
> jar:file:/D:/Installations/J2EE/Servers/ServiceMix/apache-servicemix-3.0-incubating/bin/../lib/optional/mail.jar!/META-INF/javamail.default.providers
> DEBUG: loading new provider protocol=imap,
> className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc,
> version=null
> DEBUG: loading new provider protocol=smtp,
> className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc,
> version=null
> DEBUG: loading new provider protocol=pop3,
> className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc,
> version=null
> DEBUG: getProvider() returning provider protocol=smtp;
> type=javax.mail.Provider$Type@12be8e1;
> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
> DEBUG: getProvider() returning provider protocol=smtp;
> type=javax.mail.Provider$Type@12be8e1;
> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
> DEBUG: getProvider() returning provider protocol=smtp;
> type=javax.mail.Provider$Type@12be8e1;
> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
> DEBUG: getProvider() returning provider protocol=smtp;
> type=javax.mail.Provider$Type@12be8e1;
> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
> DEBUG: getProvider() returning provider protocol=smtp;
> type=javax.mail.Provider$Type@12be8e1;
> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
> DEBUG: getProvider() returning provider protocol=smtp;
> type=javax.mail.Provider$Type@12be8e1;
> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: trying to connect to host *"localhost", port 25*  << tries to
> connect localhost & results in exception
>
> DEBUG SMTP: exception reading response:* java.net.SocketException:
> Connection reset*
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: trying to connect to host "localhost", port 25
>
> DEBUG SMTP: exception reading response: java.net.SocketException:
> Connection
> reset
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: useEhlo true, useAuth true
> DEBUG SMTP: trying to connect to host "localhost", port 25
>
>
> Any help would be appreciated.
>
>
> Thanks & Reagrds
> Pavan
>

Re: Problem while sending mail using commons email

by Siegfried Goeschl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi folks,

the email is a bit strange but if the response reaches Pavan I'm fine
... :-)

+) are you sure that your are using the same mail implementation for
your local tests and your component?
+) Have you tried upgrading JavaMail - I see "JavaMail version 1.3.1"
and this version is old

Cheers,

Siegfried Goeschl

Madhavi Kumar wrote:

> kinda tent vesi ,
> suzana aunty& whole family
> vissu,shashi
> radhivallu,manju
> mahesh,purustam
> pakanti vallu,2 familes
> On Wed, May 6, 2009 at 2:09 PM, Pavan Kumar <pavan.technology@...>wrote:
>
>  
>> Hi,
>>
>> I wrote a custom binding component to send email notifications which used
>> commons email. The problem is that the code in the component tries to
>> connect to the "localhost" even though the mail server IP is given and
>> finally end in a SocketException. The same exact piece of code with out any
>> changes works if I run it as a standalone java program.
>>
>> I did some googling and tried options like using the hostname instead of
>> IPaddress etc, but no use. The connectivity between the system I run this
>> app and the mail server is also good.
>>
>> I have set the debug on for the commons-email classes and the trace is as
>> below
>>
>> I use the following software
>>    apache-servicemix-3.0-incubating
>>    commons-email-1.1
>>
>> *Standalone java program
>> ----------------------------------------*
>> DEBUG: JavaMail version 1.3.1
>> DEBUG: java.io.FileNotFoundException:
>>
>> D:\Installations\JavaIDEs\MyEclipse\MyEclipse_5.5.1_GA\jre\lib\javamail.providers
>> (The system cannot find the file specified)
>> DEBUG: !anyLoaded
>> DEBUG: not loading resource: /META-INF/javamail.providers
>> DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
>> DEBUG: Tables of loaded providers
>> DEBUG: Providers Listed By Class Name:
>>
>> {com.sun.mail.smtp.SMTPTransport=javax.mail.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.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
>> Microsystems, Inc]}
>> DEBUG: Providers Listed By Protocol:
>> {imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
>> Microsystems, Inc],
>> pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
>> Microsystems, Inc],
>> smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
>> Microsystems, Inc]}
>> DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
>> DEBUG: !anyLoaded
>> DEBUG: not loading resource: /META-INF/javamail.address.map
>> DEBUG: java.io.FileNotFoundException:
>>
>> D:\Installations\JavaIDEs\MyEclipse\MyEclipse_5.5.1_GA\jre\lib\javamail.address.map
>> (The system cannot find the file specified)
>> DEBUG: getProvider() returning
>> javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
>> Microsystems, Inc]
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: trying to connect to host *"10.193.50.60", port 25*  <<
>> Connected correctly and mail is sent nicely
>>
>> 220 bgxius-ex01.XIUS-bcgi.ltd Microsoft ESMTP MAIL Service ready at Wed, 6
>> May 2009 12:50:09 +0530
>> DEBUG SMTP: connected to host "10.193.50.60", port: 25
>>
>> *Same code from within the binding component
>> *
>>
>> -----------------------------------------------------------------------------
>> Loading javamail.default.providers from
>>
>> jar:file:/D:/Installations/J2EE/Servers/ServiceMix/apache-servicemix-3.0-incubating/bin/../lib/optional/mail.jar!/META-INF/javamail.default.providers
>> DEBUG: loading new provider protocol=imap,
>> className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc,
>> version=null
>> DEBUG: loading new provider protocol=smtp,
>> className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc,
>> version=null
>> DEBUG: loading new provider protocol=pop3,
>> className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc,
>> version=null
>> DEBUG: getProvider() returning provider protocol=smtp;
>> type=javax.mail.Provider$Type@12be8e1;
>> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
>> DEBUG: getProvider() returning provider protocol=smtp;
>> type=javax.mail.Provider$Type@12be8e1;
>> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
>> DEBUG: getProvider() returning provider protocol=smtp;
>> type=javax.mail.Provider$Type@12be8e1;
>> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
>> DEBUG: getProvider() returning provider protocol=smtp;
>> type=javax.mail.Provider$Type@12be8e1;
>> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
>> DEBUG: getProvider() returning provider protocol=smtp;
>> type=javax.mail.Provider$Type@12be8e1;
>> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
>> DEBUG: getProvider() returning provider protocol=smtp;
>> type=javax.mail.Provider$Type@12be8e1;
>> class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: trying to connect to host *"localhost", port 25*  << tries to
>> connect localhost & results in exception
>>
>> DEBUG SMTP: exception reading response:* java.net.SocketException:
>> Connection reset*
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: trying to connect to host "localhost", port 25
>>
>> DEBUG SMTP: exception reading response: java.net.SocketException:
>> Connection
>> reset
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: useEhlo true, useAuth true
>> DEBUG SMTP: trying to connect to host "localhost", port 25
>>
>>
>> Any help would be appreciated.
>>
>>
>> Thanks & Reagrds
>> Pavan
>>
>>    
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...