我的ACTION请求后如下:
String emailaddress = "[email protected]";//这里测试是用真的邮件
String subject = "Your membership approved";
String body = "Your application for membership"; MailEngine.sendHTML(null, emailaddress, subject, body);
sendHTML方法如下:
public static void sendHTML(String from, String to, String subject,
String text) {
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
if (from == null || from.trim().length() == 0) {
from = systemEmail;
}
try {
MailAuthenticator myauth = new MailAuthenticator(user, password); Session mailSession = Session.getInstance(props, myauth); mailSession.setDebug(true); MimeMessage msg = new MimeMessage(mailSession);
if (from == null || from.trim().length() == 0) {
from = systemEmail;
}
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(text, "text/html;charset=GB2312");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart); msg.saveChanges(); Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, password);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
}
catch (Exception e) {
e.printStackTrace();
} }
然后结束,可是奇怪的是,我的邮件有的时候发出一封,有的时候发出很多封,最多的一次有九封,内容都一样,但是怎么都查不出来
1.我这里是不入数据库的,就是页面点一下调一次action发一次邮件,邮件发完结束
2.这中间没有任何循环,结束后直接返回页面,没有调其他action
3.也没有其他action调这个action
反正就外面点一下就发一下,但是居然点了一下就会发出多封邮件,郁闷啊,麻烦高手们帮忙
String emailaddress = "[email protected]";//这里测试是用真的邮件
String subject = "Your membership approved";
String body = "Your application for membership"; MailEngine.sendHTML(null, emailaddress, subject, body);
sendHTML方法如下:
public static void sendHTML(String from, String to, String subject,
String text) {
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
if (from == null || from.trim().length() == 0) {
from = systemEmail;
}
try {
MailAuthenticator myauth = new MailAuthenticator(user, password); Session mailSession = Session.getInstance(props, myauth); mailSession.setDebug(true); MimeMessage msg = new MimeMessage(mailSession);
if (from == null || from.trim().length() == 0) {
from = systemEmail;
}
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(text, "text/html;charset=GB2312");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart); msg.saveChanges(); Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, password);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
}
catch (Exception e) {
e.printStackTrace();
} }
然后结束,可是奇怪的是,我的邮件有的时候发出一封,有的时候发出很多封,最多的一次有九封,内容都一样,但是怎么都查不出来
1.我这里是不入数据库的,就是页面点一下调一次action发一次邮件,邮件发完结束
2.这中间没有任何循环,结束后直接返回页面,没有调其他action
3.也没有其他action调这个action
反正就外面点一下就发一下,但是居然点了一下就会发出多封邮件,郁闷啊,麻烦高手们帮忙
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货