this.subject = subject;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String[] getAttachFileNames() {
return attachFileNames;
}
public void setAttachFileNames(String[] attachFileNames) {
this.attachFileNames = attachFileNames;
}
public void setMsAddress(String[] msAddress) {
this.msAddress = msAddress;
}
public String[] getMsAddress() {
return msAddress;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public boolean isDebug() {
return debug;
}
public void setTimeout(long timeout) {
this.timeout = timeout;
}
public long getTimeout() {
return timeout;
}
}
public class MyAuthenticator extends Authenticator {
private String username = null;
private String password = null;
public MyAuthenticator() {
};
public MyAuthenticator(String username, String password) {
this.username = username;
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
}
注意一下:
Myeclipse自带的JavaEE5.jar和java mail会发生冲突
找到ME下的javeee包
D:\MyEclipse 8.5\Common\plugins\com.genuitec.eclipse.j2eedt.core_8.5.0.me201003231033\data\libraryset\EE_5\javaee.jar
用rar等解压工具解开javaee.jar,删除里面的javax\mail文件夹(可以先备份javaee.jar)
也即,以后都不能使用javaee.jar里面的邮件api发送邮件了.
jsp实现简单的邮件发送 , 最好有代码~~下面是我做的一个注册ACTION,发送邮件的代码齐全!有什么不明白的可以加我QQ252956244
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
package author;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Properties;
import java.util.Random;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
import classes.CISConfig;
import classes.MyAuthenticator;
import beans.AuthorsBean;
import beans.AuthorsDAO;
import beans.AuthorsFactory;
public class RegAction extends Action {
private static Logger log = Logger.getLogger(RegAction.class);
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm authorActionForm = (DynaActionForm) form;
String authorid = authorActionForm.getString("authorid");
// 判断作者编号是否存在
AuthorsFactory factory=new AuthorsFactory();
AuthorsDAO dao=factory.getAuthorsDAO();
boolean isExist = dao.isExistAID(authorid);
if (isExist == true) {
log.error("The authorid is exist,Please choose another authorid!");
ActionMessages errors = new ActionMessages();
ActionMessage error = new ActionMessage(
"errors.authorid.exist.exception", CISConfig
推荐阅读
- 包含小程序视频通话的词条
- sqlserver判断字段不为空,sql判断不为空字符串
- 玩竞速游戏,玩竞速游戏用什么手柄
- go语言实战中 go 语言实战
- 什么需要专业拍摄,专业拍摄视频需要哪些设备
- 索尼电视怎么找u盘,索尼电视怎样找到优盘
- chatgpt帮写简历,帮忙写简历怎么收费
- javaredis验证码,redis实现手机验证码的缓存
- chatgpt记会议纪要,会议记录纪要怎么写