javaMail with Lotus server



>im 面临一些 Lotus 服务器问题。负责服务器的人告诉我配置没问题,但我不能用他的 lotus 服务器发送带有 html 正文的邮件。

我得到的错误是:"554 中继因策略原因被拒绝。

当我在电脑上试用时,我使用 smpt.gmail.com 并像冠军一样工作。所以我相信不是代码问题,问题出在服务器配置上。

javaMail 和 Lotus 有问题吗?这是一个常见的问题吗?(在一个博客中,有人说不可能发送 HTML,但我不敢相信)

我的代码以防万一,

public void sendEmail(String toEmailAddr, String subject, String issue) {
    Properties props = new Properties();
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", port);
    Session mailSession = Session.getDefaultInstance(props);
    Message simpleMessage = new MimeMessage(mailSession);
    InternetAddress toAddress = null;
    InternetAddress toAddress2[] = null;
    Transport t = null ;    
    try {
        Multipart mp = new MimeMultipart();
        MimeBodyPart htmlPart = new MimeBodyPart();
        htmlPart.setContent(issue, "text/html");
        mp.addBodyPart(htmlPart);
        simpleMessage.setContent(mp);
    } catch (MessagingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }       
    try {
        toAddress = new InternetAddress(toEmailAddr);
        toAddress2 = new InternetAddress [1];
        toAddress2[0] = toAddress;          
    } catch (AddressException e) {
        // TODO LOG 
        e.printStackTrace();
    }
    try {
        simpleMessage.setRecipients(RecipientType.TO, toAddress2);
        simpleMessage.setSubject(subject);          
        t = mailSession.getTransport("smtp");       
        if(userPwd==null)
            userPwd = "";
        t.connect(host, userName, userPwd);
        t.sendMessage(simpleMessage, simpleMessage.getAllRecipients());
    } catch (MessagingException e) {
        e.printStackTrace();
        // TODO LOG 
    }finally{
        try {
            t.close();
        } catch (MessagingException e) {
            // TODO LOG 
        }
    }
}

问候。

Domino 服务器上的 SMTP 很可能已设置为仅允许某些主机进行中继 - 因此错误消息554 Relay rejected for policy reasons

您应该与管理员联系,并让他更改配置以允许其他主机中继。这是在路由器/SMTP -> 限制和控制 -> SMTP 入站控制部分的配置文档中配置的。有关 SMTP 入站中继控制的详细信息,请参阅此处:http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.help.domino.admin.doc%2FDOC%2FH_SETTING_INBOUND_RELAY_CONTROLS_STEPS.html

我遇到了同样的问题并解决了它。FROM 部分是"me@example.com"并将其更改为"myname@mydomain.com"并开始发送

可能需要

安全连接(SSL),使用以下属性连接支持smtp协议的邮件服务器:

    properties.put("mail.smtp.socketFactory.port", "SMTP_PORT");
    properties.put("mail.smtp.host", "SMTP_SERVER_HOST_NAME_OR_IP");
    properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    properties.put("mail.smtp.socketFactory.fallback", "false");

最新更新