specifying different smtp port number for Java Mail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Saurabh_Parekh
Posted On:   Friday, January 2, 2004 03:02 AM

Hi, I want to write a program that can send mails using java and am using the following jsp code : *** .... Properties props = new Properties(); props.put("mail.smtp.host", "smtphostname"); Session s = Session.getInstance(props,null); MimeMessage message = new MimeMessage(s); InternetAddress from = new InternetAddress("sample@from"); message.setFrom(from); InternetAddress to = new InternetAddress("sample@to"); message.addRecipient(Message.RecipientType.TO, to); String subject = request.getParameter("subject"); message.setSubject(subject); String text = request.getParam   More>>

Hi,

I want to write a program that can send mails using java and am using the following jsp code :

			
***
....
Properties props = new Properties();
props.put("mail.smtp.host", "smtphostname");

Session s = Session.getInstance(props,null);

MimeMessage message = new MimeMessage(s);

InternetAddress from = new InternetAddress("sample@from");
message.setFrom(from);
InternetAddress to = new InternetAddress("sample@to");
message.addRecipient(Message.RecipientType.TO, to);

String subject = request.getParameter("subject");
message.setSubject(subject);
String text = request.getParameter("text");
message.setText(text);

Transport.send(message);
....
***


The problem is that the server settings were recently
changed to a different port other than 25. However the code
above assumes the default port 25. So is there anyway by which I can specify the port number ?    <<Less

Re: specifying different smtp port number for Java Mail

Posted By:   Anin_Mathen  
Posted On:   Friday, January 2, 2004 12:28 PM

Its pretty simple...just add this statement after you put the mail.smtp.host into the properties. 888 is just my example port.

props.put("mail.smtp.port", "888");



Hope this helps..

Anin
About | Sitemap | Contact