Sending Mail in Java

String To=request.getParameter("to");
String From=request.getParameter("from");
String CC=request.getParameter("cc");
String Subject=request.getParameter("subject");
String MessageTxt = request.getParameter("message");
//Mail Starts
String smtpPort = "25";
boolean sessionDebug = false;
Properties props = System.getProperties();
props.put("", "");
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", smtpPort);
Session mailSession = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(From));
InternetAddress[] addressForMail = InternetAddress.parse(To);
msg.setRecipients(Message.RecipientType.TO, addressForMail);
msg.setSentDate(new java.util.Date());
msg.setContent(MessageTxt, "text/html");
//Mail Ends
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s