邮件发送 一般很少自己写了,用的少还可以,一次发送量过大,就会被邮件服务商给过滤掉;大概一天有150次左右的免费发送数;超过了得走收费路线了;
/** * 发送一份邮件 */ public static void seedMain() throws EmailException { HtmlEmail email = new HtmlEmail(); email.addTo("接收方邮箱地址"); // email.setSSLOnConnect(true); //是否使用SSL 传输 // email.setHostName("smtp.163.com"); email.setCharset("UTF-8"); /*阿里邮箱*/ email.setHostName("smtp.mxhichina.com");//邮件服务商 提供的服务地址 email.setSmtpPort(25); //SSL 465 email.setFrom("发送方邮箱地址"); email.setAuthentication("发送方邮箱地址", "不是邮箱密码,是邮箱的第三方密码"); StringBuilder contentBuffer = new StringBuilder(); String url = ""; contentBuffer.append("<a href='"); contentBuffer.append(url); contentBuffer.append("'>"); contentBuffer.append(url); contentBuffer.append("</a><br/>"); email.setContent(contentBuffer.toString(), "text/html;charset=utf-8"); // email.setTextMsg(contentBuffer.toString()); email.setSubject("大哥大12"); email.send();//发送 }