javax.mail.MessagingException:553 authentication is required
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/13 08:39:23
javax.mail.MessagingException:553 authentication is required,smtp2,DNGowLBbuQPU2mFIeZiQBw==.59922S2 1214372564 什么毛病?
我程序代码:
DataInputStream dis = new DataInputStream(request.getInputStream()) ;
String send = dis.readUTF() ;
String subject = dis.readUTF();
String content = dis.readUTF() ;
System.out.println(send+" -- "+subject+" -- "+content);
try {
Properties props = System.getProperties() ;
props.put("mail.smtp.host",host);
Session session = Session.getDefaultInstance(props,new MyAuthenticator()) ;
MimeMessage message = new MimeMessage(session) ;
message.setFrom(new InternetAddress(from)) ;
message.addRecipient(Message.RecipientType.TO,new
InternetAddress(send));
message.setSubject(subject) ;
message.setText(content) ;
Store store = session.getStore("pop3") ;
store.connect("pop3.163.com","****","****");
Transport.send(message) ;
} catch (Exception e) {
e.printStackTrace();
} finally{
dis.close() ;
}
我程序代码:
DataInputStream dis = new DataInputStream(request.getInputStream()) ;
String send = dis.readUTF() ;
String subject = dis.readUTF();
String content = dis.readUTF() ;
System.out.println(send+" -- "+subject+" -- "+content);
try {
Properties props = System.getProperties() ;
props.put("mail.smtp.host",host);
Session session = Session.getDefaultInstance(props,new MyAuthenticator()) ;
MimeMessage message = new MimeMessage(session) ;
message.setFrom(new InternetAddress(from)) ;
message.addRecipient(Message.RecipientType.TO,new
InternetAddress(send));
message.setSubject(subject) ;
message.setText(content) ;
Store store = session.getStore("pop3") ;
store.connect("pop3.163.com","****","****");
Transport.send(message) ;
} catch (Exception e) {
e.printStackTrace();
} finally{
dis.close() ;
}
这是javamail的验证方法中的一种
改写Authenticator的getPasswordAuthentication()方法
private class Authenticator extends javax.mail.Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
String un = user;
String pw = password;
return new PasswordAuthentication(un,pw);
}
}
应用这个之前需要设置
props.put( "mail.smtp.auth ","true ");
然后
Authenticator auth = new Authenticator();
Session mailSession = Session.getInstance(props,auth);
还有一种方法是在Transport中设置
Transport transport = mailSession.getTransport( "smtp ");
transport.connect( "mail.smtp.auth ","username ","password ");
transport.sendMessage(mimeMsg,maillist);
transport.close();
* sorze
* sorze
* 等级:
transport.connect( "mail.smtp.auth ","username ","password "); “mail.smtp.auth”应改为"smtp.163.com"或者类似的,其实写成这样就可以了transport.connect( "username ","password "); mail.smtp.host在propperties中就设置了
改写Authenticator的getPasswordAuthentication()方法
private class Authenticator extends javax.mail.Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
String un = user;
String pw = password;
return new PasswordAuthentication(un,pw);
}
}
应用这个之前需要设置
props.put( "mail.smtp.auth ","true ");
然后
Authenticator auth = new Authenticator();
Session mailSession = Session.getInstance(props,auth);
还有一种方法是在Transport中设置
Transport transport = mailSession.getTransport( "smtp ");
transport.connect( "mail.smtp.auth ","username ","password ");
transport.sendMessage(mimeMsg,maillist);
transport.close();
* sorze
* sorze
* 等级:
transport.connect( "mail.smtp.auth ","username ","password "); “mail.smtp.auth”应改为"smtp.163.com"或者类似的,其实写成这样就可以了transport.connect( "username ","password "); mail.smtp.host在propperties中就设置了
553 You are not authorized to send mail,authentication is re
You are not authorized to send mail,authentication is requir
authentication
The import javax.swing is never used
Required information is missing.
This information is required.
battery is required是什么意思
title is required是什么意思
Password is required是什么意思?
this field is required?
英语翻译Your authentication number.has been set to your E-mail.P
Your authentication number.has been set to your E-mail.Pleas