运行时tomcat信息如下: DEBUG:setDebug:JavaMail version 1.3 errorIllegal whitespace in address请问是什么意思呢?我检查过服务器和邮件地址,似乎没有什么问题。
1.连接 Properties props = System.getProperties(); // Get a Session object Session session = Session.getDefaultInstance(props, null); transport = session.getTransport("smtp"); transport.connect(mailhost, "用户名", "密码"); 2.转换地址 msg = new MimeMessage(session); msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse(mailInfo.getTo(), false));
也可以用CMail架一个邮件服务器。
Try the James,download from http://james.apache.org.The Java Apache Mail Enterprise Server (a.k.a. Apache James) is a 100% pure Java SMTP and POP3 Mail server and NNTP News server designed to be a complete and portable enterprise mail engine solution based on currently available open protocols.
比如从l63.com->21cn.com必需要设置smtp.163.com以及你的帐号和密码
Bean1.setTo("[email protected]");
Bean1.setFrom("[email protected]");
Bean1.setSubject("password");
Bean1.setBody("your pw is 123456");
Bean1.send();请问应该在哪里设置账号和密码?在javabean里面该怎样写呢?
DEBUG:setDebug:JavaMail version 1.3
errorIllegal whitespace in address请问是什么意思呢?我检查过服务器和邮件地址,似乎没有什么问题。
Properties props = System.getProperties(); // Get a Session object
Session session = Session.getDefaultInstance(props, null); transport = session.getTransport("smtp"); transport.connect(mailhost, "用户名", "密码");
2.转换地址
msg = new MimeMessage(session);
msg.setRecipients(
Message.RecipientType.TO,
InternetAddress.parse(mailInfo.getTo(), false));