com.sun.mail.smtp.smtpsendfailedexception:550访问被拒绝 - 无效的HELO


public static void main(String [] args){  
  String to="xyz@gmail.com";//change accordingly  
  final String user="abc@gmail.com";//change accordingly  
  final String password="xxxxxx";//change accordingly
  Properties pro = System.getProperties();
  pro.setProperty("mail.smtp.host", "mail.javatpoint.com");  
  pro.put("mail.smtp.auth", "true");
  Session session = Session.getDefaultInstance(pro,  new javax.mail.Authenticator() {  
       protected PasswordAuthentication getPasswordAuthentication() {  
           return new PasswordAuthentication(user,password);  
           }  
          });    
  try{
      MimeMessage message = new MimeMessage(session);
      message.setFrom(new InternetAddress(user));
      message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));  
      message.setSubject("certificate");  
      BodyPart msg = new MimeBodyPart();
      msg.setText("bodyPartMsg");
      MimeBodyPart messageBodyPart2 = new MimeBodyPart();  
      System.out.println("attach");
        String filename = "C:\Users\Rudresh Mehta\Desktop\flow for certiManipulator";//change accordingly  
      System.out.println("attach complete");
        DataSource source = new FileDataSource(filename);  
        messageBodyPart2.setDataHandler(new DataHandler(source));  
        messageBodyPart2.setFileName(filename);
        Multipart multipart = new javax.mail.internet.MimeMultipart();
        multipart.addBodyPart(msg);  
        multipart.addBodyPart(messageBodyPart2);  

        //6) set the multiplart object to the message object  
        message.setContent(multipart );  
        //7) send message  

*我的问题是为什么当它到达这里时,一旦给出运输,它就会移动到渔获物,然后从邮件中移出,并且邮件不会发送,如标题中所述,当e是在e时显示错误打印。* transport.send(消息);
system.out.println("发送消息....");

  }catch(Exception e)
  {
      System.out.print(e);
      System.out.println("in catch");
  }
  System.out.println("complete");

如果它不正确拾取本地主机名,请将邮件设置为smtp.localhost属性。

最新更新