2016-03-03 4 views
2

Я был проверен как с адреса электронной почты, так и с адреса электронной почты (с учетом регистра) и снова , и я все еще получаю сообщение 554 отклонено: адрес электронной почты не подтвержден. Отказ от SES. Но когда я пытаюсь отправить электронные письма с консоли ASUS Amazon, используя тот же адрес электронной почты, он работает нормально. Если мои сообщения и письма не были проверены, то из консоли также он должен работать. Не в состоянии понять, что происходит.554 сообщение отклонено адрес электронной почты не подтвержден. amazon ses-java

public class AmazonSESSample { 

    static final String FROM = "from email"; 
    static final String TO = "to email"; 

    static final String BODY = "This email was sent through the Amazon SES SMTP interface by using Java."; 
    static final String SUBJECT = "Amazon SES test (SMTP interface accessed using Java)"; 

    // Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials. 
    static final String SMTP_USERNAME = "SMTP USER NAME"; 
    static final String SMTP_PASSWORD = "SMTP PWD"; 

    static final String HOST = "email-smtp.us-east-1.amazonaws.com";  

    // Port we will connect to on the Amazon SES SMTP endpoint. We are choosing port 25 because we will use 
    // STARTTLS to encrypt the connection. 
    static final int PORT = 25; 

    public static void main(String[] args) throws Exception { 

     // Create a Properties object to contain connection configuration information. 
     Properties props = System.getProperties(); 
     props.put("mail.transport.protocol", "smtp"); 
     props.put("mail.smtp.port", PORT); 

     // Set properties indicating that we want to use STARTTLS to encrypt the connection. 
     // The SMTP session will begin on an unencrypted connection, and then the client 
     // will issue a STARTTLS command to upgrade to an encrypted connection. 
     props.put("mail.smtp.auth", "true"); 
     props.put("mail.smtp.starttls.enable", "true"); 
     props.put("mail.smtp.starttls.required", "true"); 

     // Create a Session object to represent a mail session with the specified properties. 
     Session session = Session.getDefaultInstance(props); 

     // Create a message with the specified information. 
     MimeMessage msg = new MimeMessage(session); 
     msg.setFrom(new InternetAddress(FROM)); 
     msg.setRecipient(Message.RecipientType.TO, new InternetAddress(TO)); 
     msg.setSubject(SUBJECT); 
     msg.setContent(BODY,"text/plain"); 

     // Create a transport.   
     Transport transport = session.getTransport(); 

     // Send the message. 
     try 
     { 
      System.out.println("Attempting to send an email through the Amazon SES SMTP interface..."); 

      // Connect to Amazon SES using the SMTP username and password you specified above. 
      transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD); 

      // Send the email. 
      transport.sendMessage(msg, msg.getAllRecipients()); 
      System.out.println("Email sent!"); 
     } 
     catch (Exception ex) { 
      System.out.println("The email was not sent."); 
      System.out.println("Error message: " + ex.getMessage()); 
      ex.printStackTrace(); 
     } 
     finally 
     { 
      // Close and terminate the connection. 
      transport.close();   
     } 
    } 
} 
+0

Мы сталкиваемся с такой же проблемой. Имеете ли вы какое-либо решение? – MasterCode

ответ

0

У меня была та же проблема, и это оказалось простой проблемой с закрытой копией. В настоящее время существует 3 региона с SES. В зависимости от региона, в котором вы устанавливаете идентификатор, переменная HOST должна быть соответствующим образом изменена.

static final String HOST = "email-smtp.us-east-1.amazonaws.com"; 

Это исправило мою проблему. Впоследствии, если вы хотите отправлять электронные письма на непроверенные адреса электронной почты, вам нужно перенести свою настройку из песочницы.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html

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