// This code is used to authenticate users on the server.Public class Email_Autherticator extends Authenticator{ Public Email_Autherticator (){ Super ();} Public PasswordAuthentication getPasswordAuthentication (){ Return new PasswordAuthentication (
/** RecieveMail. java ** Created on 2008.7.9, pm2: 40 ** To change this template, choose Tools | Template Manager * and open the template in the editor. */package mail; import javax. mail. *; import javax. mail. internet. *; import java. util. *;
1. garbled email title
The Garbled text of the mail title is well solved. You can use the mimeutility class to convert the email title. The Code is as follows:
Mailmessage. setsubject (mimeutility. encodetext (mailinfo. getsubject (), mimeutility.
Mail.java Code
The code is as follows
Copy Code
Package mail;Import java.util.*;Import java.io.*;Import javax.mail.*;Import javax.mail.internet.*;Import javax.activation.*;public class Mail {Define sender, recipient, SMTP
so it can be encapsulated into a mailadaptor.jar.
Mailadaptor Introduction Mailadaptor is an adapter that is responsible for message access, message resolution, and message generation MIME.
2# Mailadaptor core function
I have been thinking impassability, RFC822 standards have been released for many years, why there are so many inconsistent with the standard of email to appear? One may be the server's problem, and the other is the irresponsible programmer's fault.
How did you get the part?
One thing to emphasize here is that when you do not get the part object, calling Part.getcontent () can get the contents of parts. I was stuck here at the beginning. Why, then? The reason is:
Theoretically indicates that
Principle: The message can be seen as a number of parts, such as the body is a part of the attachment is a part, so use BodyPart to set the format of the message
Message.addrecipient (message.recipienttype.to,new internetaddress (mail_to));
BodyPart
1. Copy Mail.jar into the Tomcat\lib directory.2. Add the Context.xml profile in the Meta-inf under Webroot:
3. Locate the session object from the Jndi container using the Jndi API in the JSP file, index.jsp file:
"> my JSP ' index.jsp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.