i want to create an intranet maili开发者_StackOverflow中文版ng system using java.so suggest me which API and what classes to use.
Without doubts use Apache Commons Email - it's an industry standard.
Commons Email aims to provide a API for sending email. It is built on top of the Java Mail API, which it aims to simplify.
Some of the mail classes that are provided are as follows:
- SimpleEmail - This class is used to send basic text based emails.
- MultiPartEmail - This class is used to send multipart messages. This allows a text message with attachments either inline or attached.
- HtmlEmail - This class is used to send HTML formatted emails. It has all of the capabilities as MultiPartEmail allowing attachments to be easily added. It also supports embedded images.
- EmailAttachment - This is a simple container class to allow for easy handling of attachments. It is for use with instances of MultiPartEmail and HtmlEmail.
Use the JavaMail API
Take a look at http://java.sun.com/products/javamail/
Try this library: http://github.com/masukomi/aspirin
It can actually send email (some kind of embedded MTA):
public class Main { public static void main(String[] args) throws MessagingException { MailQue que = new MailQue(); MimeMessage mes = SimpleMimeMessageGenerator.getNewMimeMessage(); mes.setText("test body"); mes.setSubject("test subject"); mes.setFrom(new InternetAddress("my@local.com")); mes.setRecipients(Message.RecipientType.TO, "foo@bar.com"); que.queMail(mes); } }
精彩评论