毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> java技术 >> 正文

A secure connection is requiered(such as ssl)

更新时间:2014-1-27:  来源:毕业论文

public class MailUtil {       static int port = 587;       static String server = "smtp.qq.com";//邮件服务器mail.cpip.net.cn       static String from = "张三";//发送者,显示的发件人名字       static String user = "邮箱地址";//发送者邮箱地址       static String password = "**************";//密码            public static void sendEmail(String email, String subject, String body) throws UnsupportedEncodingException {         try {             Properties props = new Properties();             props.put("mail.smtp.host",server);             props.put("mail.smtp.port","465");             props.put("mail.smtp.auth","true");              Transport transport = null;             Session session = Session.getDefaultInstance(props, null);             transport = session.getTransport("smtp");             transport.connect(server, user, password);             MimeMessage msg = new MimeMessage(session);             msg.setSentDate(new Date());             InternetAddress fromAddress = new InternetAddress(user,from,"UTF-8");             msg.setFrom(fromAddress);             InternetAddress[] toAddress = new InternetAddress[1];             toAddress[0] = new InternetAddress(email);             msg.setRecipients(Message.RecipientType.TO, toAddress);             msg.setSubject(subject, "UTF-8");                msg.setText(body, "UTF-8");             msg.saveChanges();             transport.sendMessage(msg, msg.getAllRecipients());             transport.close();         } catch (NoSuchProviderException e) {             e.printStackTrace();         } catch (MessagingException e) {             e.printStackTrace();         }     }     public static void main(String args[]) throws UnsupportedEncodingException     {           sendEmail("lwfree@youerw.com","淫荡的人","猥琐!!");//收件人         System.out.println("ok");     }


这是错误代码


ok
javax.mail.AuthenticationFailedException: 530 Error: A secure connection is requiered(such as ssl). More information at at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
试了下
 smtp.qq.com   改成 smtp.exmail.qq.com  就好了

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。