Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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.
rubbery bacon. crispy tiny ad:
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!