How to start e-mail programming in Java
- Details
- Written by Nam Ha Minh
- Last Updated on 09 July 2019   |   Print Email
1. Official resources for JavaMail
Here are some official resources provided by Oracle for its JavaMail technology:To begin, download the latest distribution of JavaMail (which is JavaMail 1.6.2 at the time of writing this article). A JavaMail distribution comes with the following items:- License and copyright notices.
- Release changes.
- API documentation.
- Demo Java source code.
- Jar files for protocol-dependent implementation: imap.jar, pop3.jar, smtp.jar…
- Binary of the JavaMail API included in mail.jar file. This jar file is a combination of all jar files above. So to use JavaMail, only the mail.jar file is required.
2. Using JavaMail library
To compile and run code that is using JavaMail, add the mail.jar file to compile classpath and runtime classpath.If you are using Java 5 or earlier, you have to download the JavaBeans Activation Framework (JAF) and add activation.jar file to the classpath. The JAF is only included in JDK since Java 6.If you use Maven, simply specify the following dependency for your project:<dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.6.2</version> </dependency>
3. Understanding of e-mail protocols: SMTP, IMAP and POP3
Because JavaMail is based on standard e-mail protocols like SMTP, IMAP, and POP3, it’s recommended to have basic understanding of how these protocols work, as well as advantages and disadvantages of each protocol. That would help you implement your code more efficiently. Here are the links for these protocols on Wikipedia:- Simple Mail Transfer Protocol.
- Internet Message Access Protocol.
- Send e-mail in plain text using JavaMail
- Send e-mail in HTML format using JavaMail API
- Send e-mail with attachment in Java
- Receive e-mail messages from a POP3-IMAP server
- Download attachments in e-mail messages using JavaMail
- Delete e-mail messages on mail server programmatically
- Using JavaMail for searching e-mail messages
- Embedding images into e-mail with JavaMail
Comments
i want to submit contact form only what is the code for send only contact form
please help me