Javamail Api 简明教程

JavaMail API - Environment Setup

使用 Java 应用程序发送电子邮件非常简单,但首先应该在计算机上安装 JavaMail APIJava Activation Framework (JAF)

To send an e-mail using your Java Application is simple enough but to start with you should have JavaMail API and Java Activation Framework (JAF) installed on your machine.

  1. You can download latest version of JavaMail (Version 1.5.0) from Java’s standard website.

  2. You can download latest version of JAF (Version 1.1.1) from Java’s standard website.

下载并解压缩这些文件,在新建的顶层目录中,你可以找到这两个应用程序的多个 jar 文件。你需要在你的 CLASSPATH 中添加 mail.jaractivation.jar 文件。

Download and unzip these files, in the newly created top level directories you will find a number of jar files for both the applications. You need to add mail.jar and activation.jar files in your CLASSPATH.

SMTP server

要发送电子邮件,邮件服务器必须负责发送邮件。可以使用以下技巧之一来获取邮件服务器:

To send emails, you must have SMTP server that is responsible to send mails. You can use one of the following techniques to get the SMTP server:

  1. Install and use any SMTP server such as Postfix server (for Ubuntu), Apache James server (Java Apache Mail Enterprise Server)etc. (or)

  2. Use the SMTP server provided by the host provider for eg: free SMTP provide by JangoSMTP site is relay.jangosmtp.net (or)

  3. Use the SMTP Server provided by companies e.g. gmail, yahoo, etc.