gpt4 book ai didi

amazon-ses - Amazon SES 535 身份验证凭据无效

转载 作者:行者123 更新时间:2023-12-02 05:42:25 28 4
gpt4 key购买 nike

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

  • 用户(参见附图),密码
  • 访问 ID 和访问 key

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

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

    Amazon SES Users

    代码
    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();
    }
    }
    }

    最佳答案

    Important

    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 - Amazon SES 535 身份验证凭据无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21452278/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com