• 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("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");
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!