这是返回的异常信息:
Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for limi
[email protected]: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for limi
[email protected] at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at javamail.SendJavaMail.main(SendJavaMail.java:36)
Press any key to continue...
Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for limi
[email protected]: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for limi
[email protected] at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at javamail.SendJavaMail.main(SendJavaMail.java:36)
Press any key to continue...
解决方案 »
- AOP有哪些方法?居然有一个主考官这么问我,无语了。
- 特急(求大家帮帮忙)!jdbc能够连接oralce,用hibernate无法连接。
- spring不能注入的问题
- <<**紧急--共同学习**>>用JAVA实现语音输出(希望可以支持中文)
- weblogic服务变成系统服务
- 快进来看看呀~~兄弟们
- 收集一下做J2EE项目B/S结构的服务器用weblogic的多,还是用websphere的多??请大家发10秒钟的时间说一下(Thanks!!!)
- 初学J2EETutorial的问题。。。恳请高手指点一二 :)
- 没有门槛的短信平台,并且有短信分成
- web容器和ejb容器是否在一个JVM里面?什么情况下在两个JVM里面?
- 问个很菜的问题,服务器之间是怎么传递xml文件的呢?
- _mthclass$是什么呢?在什么时候调用呢,看下面的代码
import java.net.UnknownHostException;
import java.util.Date;
import java.util.Properties;import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class B2BMail {
public void SendMail( String strMailFrom, String strMailTo, String strMailSubject,
String strMailBody, String strMailErrorsTo
) throws B2BBusinessException {
String host_name = "";
try {
host_name = InetAddress.getLocalHost().getHostAddress();
} catch( UnknownHostException e ) {
throw new B2BBusinessException( B2BMessage.getMessage(2018) );
}
Properties props = System.getProperties();
props.put( "mail.smtp.host", host_name );
props.put( "mail.smtp.from", strMailErrorsTo );
Session session = Session.getDefaultInstance( props, null );
try{
MimeMessage msg = new MimeMessage(session);
InternetAddress from_adr = new InternetAddress( strMailFrom );
msg.setFrom( from_adr );
InternetAddress to_adr[] = InternetAddress.parse( strMailTo );
msg.setRecipients( Message.RecipientType.TO, to_adr );
msg.setSubject( strMailSubject, "iso-2022-jp" );
msg.setSentDate( new Date() );
msg.setText( strMailBody, "iso-2022-jp" );
Transport.send( msg );
}catch ( MessagingException e ) {
throw new B2BBusinessException( B2BMessage.getMessage(2017) + e.getMessage() );
}catch ( Exception e ) {
throw new B2BBusinessException( B2BMessage.getMessage(2017) + e.getMessage() );
}
}
}
需要认证的邮件这句话是不够的:transport.connect("smtp.tom.com","******","******");
认证的类是继承自javax,mail包中的一个类,类名我忘了,你自己搜索一下,满街都是!