Amazon SES 535 身份验证凭据无效 [英] Amazon SES 535 Authentication Credentials Invalid

查看:56
本文介绍了Amazon SES 535 身份验证凭据无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我尝试了 2 种组合

In the code below I tried 2 combinations

  1. 用户(参见附图)、密码
  2. 访问 ID 和访问密钥

两者都给出了相同的错误.我在家庭网络的 eclipse 环境中运行了这段代码.

Both gave the same error. I ran this code in my eclipse environment in my home network.

错误

Attempting to send an email through the Amazon SES SMTP interface...
The email was not sent.
Error message: 535 Authentication Credentials Invalid

代码

public class amazon_ses_smtp_test {

    static final String FROM = "someone@myemail.com";   // This has been verified on the Amazon SES setup
    static final String TO = "justanyone@anydomain";  // I have production access

    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)";

    static final String SMTP_USERNAME = "tried username and tried accesskey here";
    static final String SMTP_PASSWORD = "tried the password and the access key"; 

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

    static final int PORT = 25;

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

        Properties props = System.getProperties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.port", PORT); 

        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.starttls.required", "true");

        Session session = Session.getDefaultInstance(props);

        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");

        Transport transport = session.getTransport();

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

            transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
            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());
        }
        finally
        {
            transport.close();          
        }
    }
}

推荐答案

重要

您的 SMTP 用户名和密码与您的 AWS 访问密钥 ID 和秘密访问密钥不同.请勿尝试使用您的 AWS 凭证针对 SMTP 终端节点对您进行身份验证.有关凭证的更多信息,请参阅在 Amazon SES 中使用凭证.

Your SMTP user name and password are not the same as your AWS access key ID and secret access key. Do not attempt to use your AWS credentials to authenticate yourself against the SMTP endpoint. For more information about credentials, see Using Credentials With Amazon SES.

这是链接:http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html

这篇关于Amazon SES 535 身份验证凭据无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆