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 ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

smtp server name while using jmail  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i m working on a project where i m using jmail,
code is shown below
Properties props = new Properties();
props.put("mail.smtp.host", ""); // NOTE
Session mailSession = Session.getDefaultInstance(props, null);
MimeMessage message=new MimeMessage(mailSession);
Address addFrom=new InternetAddress("pjack@yahoo.com");
Address addTo=new InternetAddress("bback@yahoo.com");
message.setFrom(addFrom);
message.addRecipient(Message.RecipientType.TO,addTo);
message.setSubject(txtSubject);
message.setText(txtDesc);
Transport.send(message);
NOTE : I dont have any mail server, i thought of keeping it as localhost or leaving it blank.
props.put("mail.smtp.host", "");
props.put("mail.smtp.host", "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 yahoo.com, hotmail.com, aol.com.
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 mail.smtp.host 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.
Regards
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!