• Post Reply Bookmark Topic Watch Topic
  • New Topic

Able to send mail without host name  RSS feed

 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am sending e-mail through my application.
1st time when I dint mentioned my host in property file it throw's exception
so added the proper host and executed well.

After some time again I removed the host accidently and still it was working fine..what the problem can be.Also i removed the "mail.transport.protocol"=smtp ,from my property file & still it was working fine...Why its happening not able to understand??
please help me out
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without actually seeing the code and watching the application run, we're pretty much in the dark here. My guess is that you did not stop and start the application so your changes were not read in by the application.
 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do stop server after changing the property file..
My code is


import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;


public class MailUtility {
private static final String MAIL_TRANSPORT_PROTOCOL =PropertiesUtility.getKey("myproperty.properties","mail.transport.protocol");
private static final String MAIL_HOST=PropertiesUtility.getKey("myproperty.properties","mail.host");
public static void sendMail(String sendmailTo,String mailFrom,String mailSubject ,String submittedBy,String BodyContent) throws SendFailedException,MessagingException
{
Properties prop=System.getProperties();
prop.put("mail.transport.protocol",MAIL_TRANSPORT_PROTOCOL);
prop.put("mail.host",MAIL_HOST);
System.out.println("MAIL_HOST"+MAIL_HOST);
Session session = Session.getInstance(prop,null);
MimeMessage message = new MimeMessage(session);
try
{
message.setFrom(new InternetAddress(mailFrom));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(sendmailTo));
message.setSentDate(new java.util.Date());
message.setSubject(mailSubject);

String MailContent = "<html><body>" +
"<tr> <td>Subbmitted By:</td><td>"+submittedBy+"</td> </tr>" +
"<tr></tr>"+
"<tr><td>"+BodyContent+"<td> </tr>" +
"</body></html>";
message.setContent(MailContent, "text/html");
Transport.send(message);
}
catch(Exception e)
{
e.printStackTrace();
}

}

}
Is there any thing wrong in the code??
 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Please help me out with this problem it's urgent
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said "it's working fine" in your original post. So what exactly is the urgency about?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please EaseUp. Perhaps nobody knows the answer yet.
 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is If the change the body Content,Still I get the same body content as they were before changing.
Also if I delete the hostname from my programme it gets executed with the old contents which should not happen...
I guess the programme gets cached some where,but where I dont have any Idea
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this part of a web/j2ee application where you have a build/deploy cycle? It sure sounds like you have your classpath pointing at an older copy of your code.
 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes its part of Java/J2EE application,but it looks like it points to the current code ,beacuse whatever System.out.println I put in the code it show's me on the console.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!