JavaMail本地可以发送邮件,上传服务器之后出错
<%@ page contentType= "text/html;charset=gb2312 " language= "java " import= "java.sql.* "%>
<%@ page import= "java.util.* "%>
<%@ page import= "java.io.* "%>
<%@ page import= "javax.mail.*,javax.mail.internet.*,javax.activation.* "%>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
props.put( "mail.smtp.host ", "62.2.195.35 ");
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter( "from ")));
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(request.getParameter( "email ")));
newMessage.setSubject(request.getParameter( "title "));
newMessage.setSentDate(new java.util.Date());
newMessage.setText( "Hi,You have created an order on our website,Please click the link to see details. ");
transport=sendMailSession.getTransport( "smtp ");
transport.send(newMessage);
%>
<%
}
catch(
MessagingException m)
{
out.println(m.toString());
}
%>
在本地机器上程序没有问题,可以发送所有邮件,
但是上传到服务器上之后,只能发送同一域名的邮件,比如我的发件人是info@xxx.com.在服务器上只能给111@xxx.com的邮箱发邮件.如果给别的邮箱发邮件就会出现错误
javax.mail.SendFailedException: Invalid Addresses; nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, that domain isn 't allowed to be relayed thru this MTA (#5.7.1)
大家帮忙解决一下啊,3Q
------解决方案--------------------学习!
------解决方案--------------------是不是服务器无法解析对方域名?
你到服务器上ping一下外网,看看通不通。
------解决方案--------------------先检查网络