I'm running the C# code listed at https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-net.html, trying to send a test email from an EC2 instance. I can easily run the equivalent code using the gmail SMTP server, but when I use SES as my SMTP server I an SmtpException with the error message:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: Authentication required
In SES, I've done the following:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "stmt123456789",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::1234567890:user/ses-smtp-user.20190805-123456"
},
"Action": [
"ses:SendEmail",
"ses:SendRawEmail"
],
"Resource": "arn:aws:ses:us-west-2:1234567890:identity/mycompany.com"
}
]
}
My suspicion is that the problem is in my identity policy or how I've linked it back to my EC2 instance, but I don't know.
What are you using in section:
String SMTP_USERNAME = "smtp_username";
String SMTP_PASSWORD = "smtp_password";
The Sending authorization policy looks correct and more ever it is not required if your ses-smtp-user and SES verified domain in the same account, you need to make sure that you're using the credentials you created from SES console --> SMTP settings --> Credentials.
Since you're using SMTP, SMTP credentials are required, it won't work if you're using normal IAM access key and secret key. The SMTP access and secret keys should be created from SES console.