JavaMail
JavaMail | |
---|---|
Basic data
|
|
developer | Oracle |
Publishing year | 1996 |
Current version |
1.6.5 ( March 10, 2020 ) |
operating system | platform independent |
programming language | Java |
category | API |
License | CDDL 1.0, GPL 2.0, BSD |
JavaMail |
JavaMail is a Java - programming interface to platform and protocol independent send and receive e-mails . JavaMail supports the standards SMTP , POP3 and IMAP .
The JavaMail API is part of the Java EE platform, but can also be used as an optional package from the Java Standard Edition .
JavaMail has been open source since March 2, 2009 and can be obtained as a JavaMail API reference implementation from the Kenai project.
use
The following is a code fragment for the use of JavaMail 1.4.4 with the use of an SMTP server. The respective data must be obtained from the provider .
final Properties props = new Properties();
props.put("mail.smtp.host", "SMTPHOST");
props.put("mail.smtp.port", "PORTNUMBER");
props.put("mail.transport.protocol","smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.tls", "true");
props.put("mail.smtp.ssl.checkserveridentity", "true");
final javax.mail.Authenticator auth = new javax.mail.Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("EXAMPLENAME@PROVIDER.COM","PASSWORD");
}
};
Session session = Session.getDefaultInstance(props, auth);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("EXAMPLENAME@PROVIDER.COM", "EXAMPLENAME"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("TOEXAMPLE@EXAMPLEPROVIDER.COM", "TOEXAMPLE"));
msg.setSubject("SUBJECT");
msg.setText("THE MESSAGE");
msg.saveChanges();
Transport.send(msg);
Alternatives
GNU JavaMail is another open source implementation of the JavaMail API. It implements JavaMail 1.3, and in addition to the SMTP, IMAP and POP3 protocols, NNTP , UNIX mbox and Dan Bernstein's Maildir format.
Web links
Individual evidence
- ↑ JavaMail ™ API - A Technical Overview . (PORTABLE DOCUMENT FORMAT) P. 4 .
- ↑ March 10, 2020 - Jakarta Mail 1.6.5 Final Release . (accessed on May 20, 2020).
- ↑ Release 1.6.5 . March 12, 2020 (accessed May 21, 2020).
- ↑ JavaMail API reference implementation ( Memento of the original from January 22, 2011 in the Internet Archive ) Info: The archive link was inserted automatically and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. kenai.com
- ↑ GNU JavaMail Homepage