| Author |
Sending HTML format mail thru JSP
|
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
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
Joined: Feb 24, 2006
Posts: 6588
|
|
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
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
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
Joined: Mar 22, 2000
Posts: 12266
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
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
Joined: Feb 24, 2006
Posts: 6588
|
|
You cant use "session" when its already an implicit object. MimeMessage(HttpSession) does not exist. MimeMessage(Session) does
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
|
This has not a thing to do with JSP. Moved to Other Java APIs.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Rashid Mayes
Ranch Hand
Joined: Jan 11, 2006
Posts: 160
|
|
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.
|
Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
|
 |
 |
|
|
subject: Sending HTML format mail thru JSP
|
|
|