geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arun Venugopal <Arun.Venugo...@cognizant.com>
Subject javamail issue
Date Wed, 14 Dec 2005 11:31:50 GMT

Hi,

I have this piece of code that uses javamail .  This code works fine
when i try it as a standalone java application (ie when i put it in java
file, compile it and run it). But when i put this code in an war (and
call it from a servlet) and then deploy the war in geronimo, it does not
work. I am pretty sure that this code is being called as any
System.out.println that i give in between the code gets displayed in the
console. Also i tried out the same code in JBoss and it seems to work
there also. 

I have seen many discussions in the dev list regarding the JavaMail
implementation. But i think all that is with regards to creating a new
API for geronimo in the lines of the mail API's present in JBoss. And
that since i am using plain java mail it should work irrespective of the
application server.

Can any one give me any pointers on why i am having this issue in
geronimo and if i can solve it ...


-----------------------------------------------------------------------------------------------------------------------

        //substitute your mail address here
        String from = "a@b.c";
        String to = "a@b.c";
        //substitute the host name or ip of your smtp server here
        String host = "1.2.3.4";
        Properties props = new Properties();
        props.put("mail.smtp.host", host);
        props.put("mail.debug", "true");
        Session session = Session.getInstance(props);
        try {

            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(from));
            InternetAddress[] address = {new InternetAddress(to)};
            msg.setRecipients(Message.RecipientType.TO, address);
            msg.setSubject("Test E-Mail through Java");
            msg.setContent(msg, "text/plain");
            msg.setSentDate(new Date());
            msg.setText("Test Message");
            Transport.send(msg);

-------------------------------------------------------------------------------------------------------------------------



Thanks in advance

Regards
Arun



This e-mail and any files transmitted with it are for the sole use of the intended recipient(s)
and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy
all copies of the original message. 
Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of
this email or any action taken in reliance on this e-mail is strictly 
prohibited and may be unlawful.

  Visit us at http://www.cognizant.com
Mime
View raw message