Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending HTML format mail thru JSP

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,
I'm doing a dynamic website using JSP and MySQL. I want to send html format mail using JSP. How can it be possible. Please send me some links or tutorials that i can get this knowledge.

Thanks in advance

regards

Aravind Prasad
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is "html format mail" ?

Do you want the body of your mail to be of html type ? Have a look at the java mail API and the SMTP protocol.

Here is a tutorial

http://java.sun.com/developer/onlineTraining/JavaMail/contents.html
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou John Meyers,
I have looked into the JavaMail tutorial and I am not convinced with the output. I'm still getting errors while sending. I want the code for sending the mail. For that i've used this code and it is working in my localhost system, but when i uploaded to the remote server, it is not working. Can you please tell me the reason?

Here is the code


regards

Aravind Prasad
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is working when run on your local system but not on a server, the problem could be security at the mail server. Typically mail servers only accept outgoing mail from certain senders and your JSP server is not cleared to send mail through the system you are trying to use.

Bill
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
Now i'm trying to run a simple java mail application from JavaMail API tutuorial and it is showing me errors

The code is here



and the error i'm getting is here



I've added all the jar file in the classpath. Please assist me how can i fix this problem.

Thanks in advance

regards

Aravind Prasad
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cant use "session" when its already an implicit object.

MimeMessage(HttpSession) does not exist. MimeMessage(Session) does
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has not a thing to do with JSP. Moved to Other Java APIs.
 
Rashid Mayes
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When sending an message with html use the set content method of the MimeMessage class. i.e mimeMessage.setContent(htmlString,"text/html");

You may want to check the implementation of transport.send and smtptransport. I think it blocks until the first server in the delivery chain accepts the message for each recipient (cant remember exactly). If this is the case, sending the mail asynchronously will provide a better user experience especially in cases where a MX record points to a dead or slow server.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic