public class SendEmail
{
/**
* 做该例子出现的异常
* 1、Exception in thread "main" java.lang.NoClassDefFoundError:
* com/sun/mail/util/LineInputStream
*(将javaee5换成jvaee6)
* 2、Could not connect to SMTP host: localhost, port: 25
*(是端口号设置不正确,用哪个邮箱发送邮件就要设置相应的smtp host,例如,163的是smtp.163.com)
* 3、553 Local user only,163 smtp4,DtGowAAXE1vW5kBYngBsIQ--.47014S2 1480648406
* (设置的发送邮箱和端口不对应)
* 4、553 authentication is required,163 smtp4,DtGowACH2ywr50BYJRlsIQ--.16129S2 1480648491
* (这里用163邮箱发送需要验证)
* 设置property.put("mail.smtp.auth","true")注意,不是property.put("mail.smtp.auth",true)
* 重写Authenticator类的getPasswordAuthentication方法设置用户名和密码
* @param args
*/
public static void main(String[] args)
{
final String from = "XXX@163.com";