• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

smtp server name while using jmail

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("[email protected]");
Address addTo=new InternetAddress("[email protected]");
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic