采用apache commons email实现邮件的发送
public static void main(String[] args) {//创建附件信息 EmailAttachment attachment = new EmailAttachment(); attachment.setPath("f:\\b1737e2dd042fd0d1f3089f4.gif");attachment.setDisposition(EmailAttachment.ATTACHMENT);attachment.setDescription("Picture of John");attachment.setName("b1737e2dd042fd0d1f3089f4.gif");// 创建邮件信息MultiPartEmail email = new MultiPartEmail();try{email.setDebug(true);email.setHostName("smtp.yeah.net");email.setAuthenticator(new DefaultAuthenticator("username", "password"));email.addTo("ping198909@yeah.net");email.setFrom("ping198909@yeah.net");email.setSubject("The picture");email.setMsg("Here is the picture you wanted"); // 添加附件email.attach(attachment); // 发送邮件 email.send();}catch(EmailException e){e.printStackTrace();}}?