java 发送notes,发送电子邮件与Java Apache Commons通过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();

}

}

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). 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.

解决方案

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).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值