前景提要
HDC调试需求开发(15万预算),能者速来!>>>
postfix搭建好了,用outlook可以正常发送mail给gmail,在gmail中也正常收到了。
可是用javamail发送就会出现下面的错误。
javax.mail.MessagingException: 501 Syntax: HELO hostname
另外,该段程序原来在windows下是好用的,不知道为什么在rhel5下就不好用了。
查了好久,有的说需要修改hosts文件:
xxx.xxx.xxx.xxx smtp.mydomain.com
试过了,无效。
有的说,直接把程序中的smtp.mydomain.com修改为IP也是试验过了,还是无效。
还有其他的可能吗?红薯,oschina是怎么做的啊? props.put("mail.smtp.auth", "true"); props.put("mail.smtp.host", hostName) Authenticator auth = new PopupAuthenticator(username, password); Session mailSession = Session.getInstance(props, auth); Transport transport = mailSession.getTransport("smtp"); transport.connect((String) props.get("mail.smtp.host"), username, password); transport.sendMessage(mimeMsg, mimeMsg .getRecipients(Message.RecipientType.TO)); transport.close(); static class PopupAuthenticator extends Authenticator { private String strUser; private String strPwd; public PopupAuthenticator(String user, String password) { this.strUser = user; this.strPwd = password; } protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(strUser, strPwd); } } 大家能帮忙看看怎么回事吗?
好像不是postfix的问题,好像是linux服务器下跑javamail的问题。
web服务是resin