2015-06-18 5 views
0

извините за вопрос о нуле. но это работало раньше, а теперь это не так. Я не понимаю, почему.javax.mail.AuthenticationFailedException: 535 Ошибка аутентификации: Ошибка: недостаточно кредитов

смотрите коды ниже

у нас есть сервер SMTP.

он работал нормально, но после нескольких испытаний это уже было так.

Я мог бы пинговать smtp-сервер, он все еще жив.

' 
package ph.com.autoemailer.util; 

import javax.activation.DataHandler; 
import javax.activation.DataSource; 
import javax.activation.FileDataSource; 
import javax.imageio.ImageIO; 
import javax.mail.*; 
import javax.mail.internet.*; 
import javax.mail.util.ByteArrayDataSource; 

import org.apache.commons.io.IOUtils; 

import java.awt.image.BufferedImage; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileOutputStream; 
import java.io.FilenameFilter; 
import java.io.IOException; 
import java.io.InputStream; 
import java.io.OutputStream; 
import java.net.URL; 
import java.text.DateFormat; 
import java.text.SimpleDateFormat; 
import java.util.*; 

public class Mailer{ 
String d_email = "<this is not empty>", 
d_password = "<this is not empty>", 
d_host = "<this is not empty>", 
d_port = "<this is not empty>", 
m_to = "<this is not empty>", 
//m_to = "<this is not empty>", 
m_subject = "Auto-Email Notification: Receipt of Payment Confirmation FAO", 
m_text = "Hey, this is the testing email."; 
String formatMessage = ""; 
String dearGreetings; 
String sbuGreetings; 
String part1Message; 
String part2Message; 
String part2MessageImg; 
String tyMessage; 
String sbuMessage; 
String noteMessage; 
String iNoteMessage; 


@SuppressWarnings("resource") 
public Mailer(){ 
     System.out.println("Start Mailer ...... "); 
     Properties props = new Properties(); 
     props.put("mail.smtp.user", d_email); 
     props.put("mail.smtp.host", d_host); 
     props.put("mail.smtp.port", d_port); 
     props.put("mail.smtp.starttls.enable","true"); 
     props.put("mail.smtp.auth", "true"); 
     //props.put("mail.smtp.debug", "true"); 
     props.put("mail.smtp.socketFactory.port", d_port); 
     props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 
     props.put("mail.smtp.socketFactory.fallback", "false"); 
     SecurityManager security = System.getSecurityManager(); 

     try { 
      Authenticator auth = new SMTPAuthenticator(); 
      Session session = Session.getInstance(props, auth); 
      session.setDebug(true); 

      MimeMessage msg = new MimeMessage(session); 
      Multipart multipart = new MimeMultipart(); 
      MimeBodyPart attachPart = new MimeBodyPart(); 
      MimeBodyPart messageBodyPart = new MimeBodyPart(); 

      dearGreetings = "<this is not empty>"; 
      sbuGreetings = "<this is not empty>"; 

      part1Message = "<this is not empty>"; 

      part2Message = "<this is not empty>"; 

      part2MessageImg = "<this is not empty>";; 
      tyMessage = "Yours truly,<br/><br/><br/>"; 

      sbuMessage = "<this is not empty>"; 

      noteMessage = "<this is not empty>"; 

      iNoteMessage = "<this is not empty>"; 

      formatMessage = dearGreetings+sbuGreetings+part1Message+part2Message+part2MessageImg+tyMessage+sbuMessage+noteMessage+iNoteMessage; 
      m_text = formatMessage; 
      msg.setText(m_text); 
      msg.setSubject(m_subject); 
      msg.setFrom(new InternetAddress(d_email)); 
      msg.addRecipient(Message.RecipientType.TO, 
        new InternetAddress(m_to)); 

      multipart.addBodyPart(messageBodyPart); 
      multipart.addBodyPart(attachPart); 
      msg.setContent(multipart); 

      // creates body part for the attachment 

      messageBodyPart.setContent(formatMessage, "text/html"); 

      InputStream inputStream = null; 
      OutputStream outputStream = null; 

      String attachFile = "<this is not empty>"; 
      // read this file into InputStream 
      inputStream = new FileInputStream(attachFile); 
      byte[] bytesInputStream = IOUtils.toByteArray(inputStream); 
      Date getDateToday = new Date(); 
      SimpleDateFormat formatDateToday = new SimpleDateFormat("yyyyMMdd"); 
      String finishFormatDate = formatDateToday.format(getDateToday); 
      // write the inputStream to a FileOutputStream 
      outputStream = new FileOutputStream(new File("<this is not empty>"+".pdf")); 

      String convertedattachFile = "<this is not empty>"+".pdf"; 

      DataSource source = new ByteArrayDataSource(bytesInputStream, "application/pdf");//new FileDataSource(convertedattachFile); 

      attachPart.setDataHandler(new DataHandler(source)); 
      attachPart.setFileName(new File(attachFile).getName()); 
      Transport.send(msg); 
     } catch (Exception mex) { 
      mex.printStackTrace(); 
     }finally{ 
      System.out.println("Email Is Sending..."); 
     } 
    } 

    private class SMTPAuthenticator extends javax.mail.Authenticator { 
     public PasswordAuthentication getPasswordAuthentication() { 
      return new PasswordAuthentication(d_password, d_password); 
     } 
    } 

    public static void main(String[] args) { 
      Mailer blah = new Mailer(); 
    } 


} 

здесь является результатом ошибки

Start Mailer ...... 
DEBUG: setDebug: JavaMail version 1.5.3 
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle] 
DEBUG SMTP: need username and password for authentication 
DEBUG SMTP: useEhlo true, useAuth true 
DEBUG SMTP: trying to connect to host "smtp.elasticemail.com", port 2525, isSSL false 
220 smtp.elasticemail.com ESMTP 
DEBUG SMTP: connected to host "smtp.elasticemail.com", port: 2525 

EHLO 10.24.51.120 
250-smtp.elasticemail.com 
250-PIPELINING 
250-SIZE 20971520 
250-8BITMIME 
250-AUTH=PLAIN LOGIN CRAM-MD5 
250-AUTH PLAIN LOGIN CRAM-MD5 
250-STARTTLS 
250 OK 
DEBUG SMTP: Found extension "PIPELINING", arg "" 
DEBUG SMTP: Found extension "SIZE", arg "20971520" 
DEBUG SMTP: Found extension "8BITMIME", arg "" 
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN CRAM-MD5" 
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN CRAM-MD5" 
DEBUG SMTP: Found extension "STARTTLS", arg "" 
DEBUG SMTP: Found extension "OK", arg "" 
STARTTLS 
220 Begin TLS negotiation 
EHLO 10.24.51.120 
250-smtp.elasticemail.com 
250-PIPELINING 
250-SIZE 20971520 
250-8BITMIME 
250-AUTH=PLAIN LOGIN CRAM-MD5 
250-AUTH PLAIN LOGIN CRAM-MD5 
250-STARTTLS 
250 OK 
DEBUG SMTP: Found extension "PIPELINING", arg "" 
DEBUG SMTP: Found extension "SIZE", arg "20971520" 
DEBUG SMTP: Found extension "8BITMIME", arg "" 
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN CRAM-MD5" 
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN CRAM-MD5" 
DEBUG SMTP: Found extension "STARTTLS", arg "" 
DEBUG SMTP: Found extension "OK", arg "" 
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed 
DEBUG SMTP: AUTH LOGIN failed 
javax.mail.AuthenticationFailedException: 535 Authentication failed: Error: Not enough credit. 

Email Is Sending... 
    at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:892) 
    at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:814) 
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728) 
    at javax.mail.Service.connect(Service.java:386) 
    at javax.mail.Service.connect(Service.java:245) 
    at javax.mail.Service.connect(Service.java:194) 
    at javax.mail.Transport.send0(Transport.java:253) 
    at javax.mail.Transport.send(Transport.java:124) 
    at ph.com.autoemailer.util.Mailer.<init>(Mailer.java:140) 
    at ph.com.autoemailer.util.Mailer.main(Mailer.java:173) 

ответ

0

Эта ошибка является пользовательской ошибки. Вероятно, услуга elasticemail - это услуга payd, и у вас недостаточно кредитов для отправки электронных писем.

Проверьте свою кредитоспособность.

+0

haha ​​!! yeahh, клиент забыл, что у него больше нет кредитов .. почти потерял мой разум из-за этого .. dang. –

+0

Если вы найдете этот ответ полезным, вы можете его проголосовать и отметить, что он имеет правильный ответ (с зеленой проверкой) –

+0

ow okay приятно знать .. :) было полезно .. –

Смежные вопросы