This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Mail API  RSS feed

 
akhil achuthan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried my mail appln by giving host as localhost and addresses xxx@localhost.com

still it dosnt work.........

the sample code i developed

import java.mail.*;
import java.mail.internet.*;
importutil.Properties.*;

class Sending
{
Public static void main(String args[])
{
try
{
Properties prop = new Properties();
prop.put=("mail.smtp.host","localhost");
Session session = Session.getDefaultInstance(prop,null);
MimeMessage messag = new MimeMessage(session);
Address from = new InternetAddress("xxx@yahoo.co.in");
Address to = new InternetAddress("yyy@localhost.com");
message.setContent("Samplemail","text/plain");
message.setSubject("SM");
message.setFrom(from);
message.addRecepient(Message.Recepient.Type.TO,to );
}
}
}
 
Thara Visu
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akhil,
What are you trying to do exactly?
What error are you getting?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "...@localhost.com" address is not the same as "...@localhost" (unless your hosts file specifies that localhost.com is the same as localhost). Try it without the ".com"
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!