发送电子邮件与Java Apache Commons通过Lotus Notes邮件 [英] Sending email with java Apache Commons Mail through Lotus Notes

查看:872
本文介绍了发送电子邮件与Java Apache Commons通过Lotus Notes邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在电子邮件配置中遇到问题,可以在java程序中使用Lotus Notes发送电子邮件。我知道这是非常简单的,但我想我错过了一些东西。我的代码如下:

I'm having trouble with my e-mail configuration for sending e-mails using lotus notes in a java program. I know this is pretty much straight forward but i guess i'm missing something. My code is as follows;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class MailClass {

    public void SendMail() {
        SimpleEmail email = new SimpleEmail();

    try {
        email.setHostName("mail.smtp.host");
        email.addTo("recipient@company.com");
        email.setFrom("sender@agency.com");
        email.setSubject("Hello World");
        email.setMsg("This is a simple test of commons-email");
        email.send();

    } catch (EmailException ex) {
        Logger.getLogger(MailClass4.class.getName()).log(Level.SEVERE, null, ex);
    }
}

public static void main(String[] args) {
    MailClass main = new MailClass();
    main.SendMail();
  }
}

我继续收到此错误

SEVERE: null
org.apache.commons.mail.EmailException: Sending the email to the following server     failed : mail.smtp.host:25
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
...
Caused by: javax.mail.MessagingException: Unknown SMTP host: mail.smtp.host;
nested exception is:java.net.UnknownHostException: mail.smtp.host at    com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1970)

我猜这是关于我的主机,但不知道该怎么做。从我的理解,您的主机应该是您的电子邮件客户端(例如mail.smtp.google.com)。但是由于这是Lotus Notes(它在我们的Intranet btw中运行),因此它的含义将不同。我看到其他使用mail.smtp.host作为主机的样本,但我无法得到这个正确的...
这是我第一次做一个电子邮件程序,所以我很漂亮对此很无能为力。

I'm guessing it's about my host but not really sure what to do about it. From my understanding your host should be your email client (ex. mail.smtp.google.com). But since this is Lotus Notes (it runs in our intranet btw) the implimentation will be different. I've seen other samples that use the "mail.smtp.host" as host but i can't get this one right.... It's my first time doing an e-mail program so i'm pretty much clueless about this.

推荐答案

您可以将运行在Intranet上的Domino服务器用作SMTP服务器,但首先您必须询问管理员Domino是否已经设置为允许SMTP - 同时请求正确的主机名和端口)。

You can use your Domino server running on your intranet as SMTP server but first you have to ask your admin if Domino has been set up to allow SMTP - and at the same time ask for the proper host name and port).

这篇关于发送电子邮件与Java Apache Commons通过Lotus Notes邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆