简体   繁体   English

通过Lotus Notes使用Java Apache Commons Mail发送电子邮件

[英]Sending email with java Apache Commons Mail through Lotus Notes

I'm having trouble with my e-mail configuration for sending e-mails using lotus notes in a java program. 我的电子邮件配置无法在java程序中使用Lotus Notes发送电子邮件。 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();
  }
}

I keep on getting this error 我继续得到这个错误

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)

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). 据我了解,您的主机应该是您的电子邮件客户端(例如mail.smtp.google.com)。 But since this is Lotus Notes (it runs in our intranet btw) the implimentation will be different. 但由于这是Lotus Notes(它在我们的Intranet btw中运行),所以暗示将是不同的。 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. 我见过其他使用“mail.smtp.host”作为主机的样本,但我无法正确使用这个......这是我第一次做一个电子邮件程序,所以我对这个很无能为力。

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

setHostName requires the hostname or IP-address of a smtp server. setHostName需要smtp服务器的主机名或IP地址。 And the exception makes it very clear what the issue is. 例外情况非常清楚问题是什么。

Lotus Notes is basicslly just a client and has nothing to do with what you are trying to accomplish. Lotus Notes基本上只是一个客户端,与您要完成的任务无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM