|
|
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.
|
|

05-26-2008, 09:50 AM
|
|
Member
|
|
Join Date: Apr 2008
Location: villupuram
Posts: 22
|
|
|
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
|
|

05-26-2008, 09:58 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

05-26-2008, 01:04 PM
|
|
Member
|
|
Join Date: Apr 2008
Location: villupuram
Posts: 22
|
|
|
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
|
|

05-26-2008, 01:09 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

05-27-2008, 01:51 AM
|
 |
Member
|
|
Join Date: Apr 2007
Location: Midwest
Posts: 60
|
|
|
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.
|
|

05-27-2008, 05:47 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 5,075
|
|
|
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.
|
|

05-27-2008, 08:34 AM
|
|
Member
|
|
Join Date: Apr 2008
Location: villupuram
Posts: 22
|
|
|
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();
}
|
|

05-27-2008, 03:37 PM
|
 |
Member
|
|
Join Date: Apr 2007
Location: Midwest
Posts: 60
|
|
|
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.
|
|

05-28-2008, 09:00 AM
|
|
Member
|
|
Join Date: Apr 2008
Location: villupuram
Posts: 22
|
|
|
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
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|