James2.3.2运行在ubuntu上面,ruby也在上面,本地代码测试发邮件居然错误。
Jame运行后,在里面增加两个账号paul和sandy。
smtpserver日志,AUTH method LOGIN failed这样的错误信息根本搞不清楚根本原因。
27/06/12 00:15:03 INFO smtpserver: SMTP Service uses default thread group.
27/06/12 00:15:03 INFO smtpserver: SMTP Service is running on: ubuntu
27/06/12 00:15:03 INFO smtpserver: SMTP Service handler hello name is: ubuntu
27/06/12 00:15:03 INFO smtpserver: SMTP Service handler connection timeout is:
360000
27/06/12 00:15:03 INFO smtpserver: SMTP Service connection backlog is: 5
27/06/12 00:15:03 INFO smtpserver: SMTP Service will allow a maximum of 30 conn
ections.
27/06/12 00:15:03 INFO smtpserver: This SMTP server requires authentication, bu
t doesn't verify that the authentication credentials match the sender address.
27/06/12 00:15:03 INFO smtpserver: Authorized addresses: [127.0.0.0/255.0.0.0]
27/06/12 00:15:03 INFO smtpserver: No maximum message size is enforced for this
server.
27/06/12 00:15:03 INFO smtpserver: The idle timeout will be reset every 20480 b
ytes.
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.VrfyCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.AuthCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.QuitCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.HelpCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.HeloCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.MailCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.DataCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.RcptCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.EhloCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added MessageHandler: org.apache.james.smtps
erver.SendMailHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.NoopCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.ExpnCmdHandler
27/06/12 00:15:03 INFO smtpserver: Added Commandhandler: org.apache.james.smtps
erver.RsetCmdHandler
27/06/12 00:15:03 INFO smtpserver: SMTP Service started plain:25
27/06/12 00:19:54 INFO smtpserver: Connection from localhost (127.0.0.1)
27/06/12 00:21:55 INFO smtpserver: Connection from localhost (127.0.0.1)
27/06/12 00:21:55 ERROR smtpserver: AUTH method LOGIN failed
27/06/12 00:22:54 INFO smtpserver: Connection from localhost (127.0.0.1)
27/06/12 00:22:54 ERROR smtpserver: AUTH method LOGIN failed
James配置,修改部分
增加了一个servername配置
<servernames autodetect="true" autodetectIP="true">
<!-- CONFIRM? -->
<servername>localhost</servername>
<servername>ubuntu</servername>
</servernames>
需要登录
<authRequired>true</authRequired>
----------------------------------------------------------------------
ruby代码
require 'net/smtp'
msg = "Subject: Sendmail test Hi There!\n\nThis works, and this part is in the body."
smtp = Net::SMTP.new 'localhost', 25
#smtp.enable_starttls
smtp.start('localhost','paul@localhost', '123456', :login) do
smtp.send_message(msg, 'paul@localhost', 'sandy@localhost')
end
报错误
/home/lxiaodao/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:971:in `check_auth_response': 535 Authentication Failed (Net::SMTPAuthenticationError)
from /home/lxiaodao/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:759:in `auth_login'
from /home/lxiaodao/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:735:in `authenticate'
from /home/lxiaodao/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:570:in `do_start'
from /home/lxiaodao/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
from localsend.rb:6:in `<main>'
基本怀疑James auth plain有bug,没有心情去继续深入追究,换邮件服务器。
http://www.jezzper.com/jezzper/Discussions.nsf/f72637182738a22ec1257082007010ef/4baacde21bddba9dc1256f63006a6e30!OpenDocument
Chris Means wrote:
> I've not seen this problem mentioned before.
Which tells us that AUTH PLAIN isn't in wide use.
> I keep getting a SMTP Authentication Failed (535).
It appears that our AUTH PLAIN implementation is wrong. Outlook works
because it uses AUTH LOGIN, which we do have implemented properly.
I have a fix locally, and will commit to CVS. It is a one liner, if you
want to make it in your copy.
> smtpserver: Command received: AUTH PLAIN Y21lYW5zAGNtZWFucwBaYXBob2Q=
You do realize that you have to change your password, right? You just gave
it out to everyone.
======================================================================
又经过一些时间分析,使用比较熟悉的Java代码来测试,发现上面的ruby代码有潜在问题,估计是协议支持问题,后续再多花时间分析。
public void sendlocal(String[] args){
String host = "localhost";
String from = "paul@localhost";
String[] to = {"sandy@localhost"}; // added this line
if(args!=null){
to=new String[]{args[0]};
if(args.length>=2&&args[1]!=null){
from=args[1];
}
}
String pass = "123456";
Properties props = System.getProperties();
//props.put("mail.smtp.starttls.enable", "true"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
try {
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];
// To get the array of addresses
for( int i=0; i < to.length; i++ ) { // changed from a while loop
toAddress[i] = new InternetAddress(to[i]);
}
System.out.println(Message.RecipientType.TO);
for( int i=0; i < toAddress.length; i++) { // changed from a while loop
message.addRecipient(Message.RecipientType.TO, toAddress[i]);
}
message.setSubject("Sending in a group");
message.setText("Welcome to JavaMail");
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("send mail correct!!");
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
}
分享到:
相关推荐
Apache James邮件服务器是一款开源的、基于Java的全功能邮件服务器,它支持SMTP、POP3和IMAP协议,为企业和个人提供了一种可靠且可扩展的邮件处理解决方案。在本项目中,我们将探讨如何利用Apache James来实现邮件的...
Java开源邮件服务器Apache James是基于Java技术构建的一款强大的邮件服务器软件。它的源代码开放,允许开发者深入了解其工作原理,并可根据需求进行定制化开发。Apache James 2.3.2是该项目的某个稳定版本,提供了...
james 邮件服务器 详细配置 关联数据库
James邮件服务器是一款由Apache组织开发的开源邮件服务器,完全用Java编写,具备高度的灵活性和可扩展性。这款服务器不仅支持SMTP和POP3协议,还实现了NNTP新闻服务器功能,使其成为一款全面的企业级邮件解决方案。 ...
本文主要介绍如何使用 James 搭建邮件服务器。 首先,你需要从官方下载地址获取 James 的安装包,例如版本 2.3.2.1。下载完成后,将其解压到指定目录,例如 C:\james-2.3.2.1。在安装前,确保已经正确设置了 JAVA_...
在提供的`james3.0.4beta内外网收发讲解.doc`文档中,应该详细描述了上述所有步骤,包括具体的配置命令、代码示例和可能遇到的问题及解决方法。通过仔细阅读这份文档,你可以掌握James服务器的完整配置过程,为你的...
James 3.0.1 是一个开源的邮件服务器软件,基于Java技术构建,提供全面的邮件服务功能。本文将深入探讨如何配置 James 3.0.1,使其能够有效地运行并满足您的邮件服务需求。 首先,我们需要理解James的核心组件和...
### Apache邮件服务器James简单配置详解 #### 背景与简介 Apache James是Apache软件基金会下的一个开源邮件服务器项目,完全基于Java语言构建,具备高度的可配置性和扩展性,同时确保了系统的稳定性。它提供了包括...
Apache James邮件服务器,内部邮件的收发,包括删除
**James邮件服务器** James邮件服务器是Apache软件基金会开发的一个开源邮件服务器项目,它是一个完全用Java编写的网络应用程序。这个服务器提供了多种邮件服务功能,包括SMTP(简单邮件传输协议)、POP3(邮局协议...
apache-james 是apache旗下的开源项目,为企业架设内部及外部服务器再添便利!!!
**James邮件服务器详解** James邮件服务器是一款开源的、基于Java技术构建的邮件传输代理服务器,其版本号为2.3.2。这个软件提供了一整套邮件服务解决方案,包括SMTP(简单邮件传输协议)、POP3(邮局协议版本3)和...
James_邮件服务器配置James_邮件服务器配置James_邮件服务器配置James_邮件服务器配置James_邮件服务器配置James_邮件服务器配置James_邮件服务器配置
Apache James是一款开源的、完全基于Java的邮件服务器,它提供了企业级的邮件处理能力,包括邮件的接收、发送以及管理等功能。这篇配置说明主要指导如何搭建并使用Apache James,以便于构建免费的企业邮件系统。 ...
Apache James 3.0.1 是一款开源且免费的邮件服务器软件,专为处理电子邮件通信而设计。这个软件项目由Apache软件基金会维护,提供了一种高效、可扩展且灵活的解决方案,适合各种规模的企业和组织使用。James的核心...
Apache James邮件服务器是一款开源的邮件服务器软件,基于Java平台,实现了SMTP、POP3和IMAP4等邮件协议,为企业和个人提供了稳定、可扩展的邮件服务解决方案。本篇将深入探讨如何配置Apache James邮件服务器。 ...
### Apache James 邮件服务器配置详解 #### 一、背景与动机 随着互联网的发展,邮件作为信息传递的重要工具之一,被广泛应用于个人通讯及企业内部交流。然而,许多公共邮件服务商如163、新浪等为了防止垃圾邮件的...
Apache James邮件服务器用户信息的数据库存储问题.doc
**James邮件服务器详解** James(Java Apache Mail Enterprise Server)是一个开源的、基于Java技术的邮件服务器,它在邮件处理和管理方面提供了全面的功能。版本2.3.2是该服务器的一个稳定版本,提供了多种特性来...