Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-26-2008, 09:50 AM
Member
 
Join Date: Apr 2008
Location: villupuram
Posts: 22
sundarjothi is on a distinguished road
Send a message via AIM to sundarjothi
Java mail problem(working in intranet,but not working in iternet)
Hi everyone,

I have a little problem with my java mail coding.
While i was using java mail coding in local netwok(intranet) properly executing.
But i was used in internet, it is not working.
I told my problem(java mail is not working prperly) to my server maintainer(service provider).
They told "we loaded all mandatory jar files in Tomcat server please verify your coding"
And told " please check your smtp protocal" and wrote code
u shoud use smtp as 25

other things asp and php coding are not supported in java server ..
u should send mail coding through jsp
Please check once & let us know if any problems !
Please let us know the error URL / Path if you have any more problems, thanks


please refer my coding and tell what is wrong with coding

Properties props = System.getProperties();
props.put("mail.smtp.host", host);
//props.put("mail.debug", "true");
Session session = Session.getInstance(props, null);
//session.setDebug(debug);

try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);

// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msgText1);

// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();

// attach the file to the message
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());

// create the Multipart and add its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);

// add the Multipart to the message
msg.setContent(mp);

// set the Date: header
msg.setSentDate(new java.util.Date());

// send the message
Transport.send(msg);
flag=true;


}catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
}


please reply immediately

thanks
sundar
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-26-2008, 09:58 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Did you get any exception on your code?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-26-2008, 01:04 PM
Member
 
Join Date: Apr 2008
Location: villupuram
Posts: 22
sundarjothi is on a distinguished road
Send a message via AIM to sundarjothi
Urgent
hi thanks,
i didnt get any exception in my program.
program still working in local network(intranet).
But program not working in internet(www).
If any changes in my program ,
please reply me.

regrads
sundar
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-26-2008, 01:09 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I'm looking an exception on internet. Did you debug and try on the net?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-27-2008, 01:51 AM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
Does the smtp server that you are using to send out the email need a userid and password to access it? I use the gmail api to send mail via my java app and I need to supply my id and password, most smtp hosts require that.
If you are not getting any exceptions I would take a look at the host you are sending thru.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-27-2008, 05:47 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
You mean some kind of authentication issue can be take place there in the internet.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-27-2008, 08:34 AM
Member
 
Join Date: Apr 2008
Location: villupuram
Posts: 22
sundarjothi is on a distinguished road
Send a message via AIM to sundarjothi
Help
Hi
thanks,
I did not use any authentication in my program .
please verify my program and reply me
If any changes need in my program.

regards
sundar

This is my coding sample

Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", 25);
//props.put("mail.debug", "true");
Session session = Session.getDefaultInstance(props, null);
//session.setDebug(debug);

try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);

// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msgText1);

// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();

// attach the file to the message
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());

// create the Multipart and add its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);

// add the Multipart to the message
msg.setContent(mp);

// set the Date: header
msg.setSentDate(new java.util.Date());

// send the message
Transport.send(msg);
flag=true;


}catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
}
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 05-27-2008, 03:37 PM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
Let me ask you this. What smtp gateway are you using to send your mail out?? Is it open, meaning can anyone in the world use it?
Or is it your company smtp gateway?
Or is it something else? Unless it is totally open, most smtp gateways have some sort of rules for using them.
Just start by telling us that, it will help debug this issue.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 05-28-2008, 09:00 AM
Member
 
Join Date: Apr 2008
Location: villupuram
Posts: 22
sundarjothi is on a distinguished road
Send a message via AIM to sundarjothi
Help
Hi orchid,

i just used company smtp server only.
i did not give username,password in our company server( that means
authentication not provided in my mail coding).
I have doubt about authentication in my code.
It may cause any problem to prevent mail send to server.

please reply me.

regards,
sundar
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP send mail script not working. profuse Java Applets 1 05-27-2008 08:37 AM
Working with the DOM parser JavaForums Java Blogs 0 04-21-2008 06:40 PM
working with mp3 in java po0oker Advanced Java 1 10-30-2007 10:20 PM
working with servlets Freddie Java Servlet 2 05-15-2007 07:50 PM
Working With ANT JavaForums Eclipse 0 04-26-2007 10:16 PM


All times are GMT +3. The time now is 12:09 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org