try {
InternetAddress to = new InternetAddress("[email protected]");
InternetAddress from = new InternetAddress("[email protected]");
String sub = new String("test");
String body = new String("test-mail");
MailMessage msg = new MailMessage();
msg.setTo(to);
msg.setFrom(from);
msg.setBody(body);
msg.setSubject(sub);
MailServiceUtil.sendEmail(msg);
MailEngine.send(from, to, sub, body);
} catch (Exception e) {
System.out.println("can't send mail");
}
MailServiceUtil.sendEmail(msg);
发送电子邮件这种方式只是没有工作不能支持Liferay
MailEngine.send(from, to, sub, body);
这样给我说的错误:
Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
我应该怎么做让它起作用?
谢谢你,我已经尽力通过ROOT.xml和控制面板设置我的SMTP属性,你有另一个想法吗? – user1075116
@ user1075116你在哪里设置用户名和密码?有一个例子适合你吗? – stacker