protected void sendEmail(String logo_src,String hostName,String receiver,String sender,String senderName, String userName,String password,String subject,URL url,String name,String htmlMsg){ HtmlEmail email = new HtmlEmail(); email.setCharset("UTF-8"); try { email.setHostName(hostName); //SMTP发送服务器的名称 email.addTo(receiver); //收件人邮箱 email.setFrom(sender, senderName); //发送人邮箱和发送人名 email.setSSLOnConnect(true); email.setAuthenticator(new DefaultAuthenticator(userName,password)); //认证信息,分别为发件人在邮件服务器上的注册名称和密码 email.setSubject(subject); //邮箱主题 logo_src = email.embed(url, name); email.setHtmlMsg(htmlMsg); //邮箱HTML内容 email.setTextMsg("您的邮箱不支持HTML格式的邮件!"); email.send(); } catch (EmailException e) { e.printStackTrace(); } }