• Post Reply Bookmark Topic Watch Topic
  • New Topic

javamail webapplication  RSS feed

 
sreedhar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
my requirement is i want javamail application is only for sending the particular given recepent id in tomcat by using smtp i m trying can u pls anybody help me finding the solution for my problem r else send me any code for my reqirement . this is my mail id sreedhar.methuku@gmail.com
i tried like this
import javax.mail.Address;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import Mailer.java;

public class Mail{
public Mail(){}
String frommail="jyotsnak@globarena.com";
String tomail = request.getParameter("tomail");
String sub = request.getParameter("sub");
String textarea = request.getParameter("textarea");
boolean multipart = true;
String smtphost = "mail.net4india.com";
public static void main(String args[])
{
sendMail(smtphost,frommail,tomail,sub,textarea);
}
}

public void sendMail(String smtp_host, String from, String to, String subject, String message) throws AddressException, MessagingException
{
try{
Message msg = prepareHeader(smtp_host, from, to, subject);
msg.setContent(message, "text/plain");
Transport transport = session.getTransport("smtp");
transport.connect(smtp_host, null, null);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
}catch(AddressException ae)
{
ae.printStackTrace();
}
catch(MessagingException me)
{
me.printStackTrace();
}

}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!