当前位置: 代码迷 >> Lotus >> 怎么用JSP发送邮件给Lotus Notes
  详细解决方案

怎么用JSP发送邮件给Lotus Notes

热度:91   发布时间:2016-05-05 07:10:41.0
如何用JSP发送邮件给Lotus Notes
公司内部邮件系统用的Lotus   Notes   6.5.现在需要在某个工作提交后发送一些内部邮件提醒相关人员.我用java写的代码在外网通过 "163邮件服务器 "发邮件给内网没问题,但在在内部怎样测试都不成功.公司防火墙限制了内网与外网的smtp协议.
我是新手,对lotus很陌生,请大家给点内部发邮件的思路,是不是可以设置通过 "内部邮件服务器 "发送邮件呢?参数如何设置?如何实现呢?

------解决方案--------------------
楼主可以参照我的代码:我测试是通过的,但是没有Lotus SMTP的验证。
<[email protected] contentType= "text/html;charset=gb2312 "%>
<%@ page import= "java.util.*, javax.mail.*, javax.mail.internet.* " %>
<html>
<head>
<title> JavaMail sending test </title>
</head>
<body>
<%
String smtphost = "vinson "; //Domino smtphost,you should make sure the smtp service is opened in domino Server
String user = " ";
String password = " ";
String from = "admin ";
String to = "admin ";
String subject = "Java Mail Subject! ";
String body = "Java Mail Body! ";
// the following is mail sending program,user needn 't to revise it
try {
Properties props = new Properties();
props.put( "mail.smtp.host ", smtphost);
props.put( "mail.smtp.auth ", "true ");
Session ssn = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(ssn);
InternetAddress fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
InternetAddress toAddress = new InternetAddress(to);
message.addRecipient(Message.RecipientType.TO, toAddress);
message.setSubject(subject);
message.setText(body);
Transport transport = ssn.getTransport( "smtp ");
transport.connect(smtphost, user, password);
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
//transport.send(message);
transport.close();
%> <p> your Mail has been sent,please return**C </p> <%
} catch(Exception m) {
out.println(m.toString());
}%>
</BODY>
</HTML>
  相关解决方案