posted 21 years ago
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