Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

smtp server name while using jmail  RSS feed

Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m working on a project where i m using jmail,
code is shown below
Properties props = new Properties();
props.put("", ""); // NOTE
Session mailSession = Session.getDefaultInstance(props, null);
MimeMessage message=new MimeMessage(mailSession);
Address addFrom=new InternetAddress("");
Address addTo=new InternetAddress("");
NOTE : I dont have any mail server, i thought of keeping it as localhost or leaving it blank.
props.put("", "");
props.put("", "localhost");
but it is throughing exception saying that no mail server exist.
My question is, is it neccessary to mention the mail server, when i want to send mails to people, where in there id consist of,,
If so with different mail ids which server name shall i put in the properties so that it works fine.

thanks in advance
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sun,
Ask the network administrator in your company to give you the host name (or IP address) of a SMTP server you may use to send mail outside.
If you're planning on using this from home, use the SMTP host that is given by your Internet Service Provider (or ask them if you can't find it).
Then use this host name or IP to fill the property.
Java Mail absolutely needs a SMTP server to send email. If you want to use localhost, then you will have to install a SMTP server on your machine.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!