2

I am trying to send email using aws-sdk's SES in my Angular application (Angular 5).

ses = new AWS.SES({
    apiVersion: '2010-12-01',
    accessKeyId:'<<access key>>',
    secretAccessKey:'<<secretkey>>',
    region: 'us-east-1',
    endpoint: 'email-smtp.us-east-1.amazonaws.com',
    sslEnabled: true
  });

this.ses.sendEmail(this.params, function(err, data) {
      if (err) {
        console.log(err, err.stack); // an error occurred
        console.log("Got error:", err.message);
        console.log("Request:");
        console.log(this.request.httpRequest);
        console.log("Response:");
        console.log(this.httpResponse);
      } else {
        console.log(data);           // successful response
      }   
    });

I am getting the below error.

Failed to load https://email-smtp.us-east-1.amazonaws.com/: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

I don't find a way to set the header values here.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • this.params refers to the email details, (sender,subject,... etc) – ArunPrasath S Apr 29 '18 at 17:27
  • Possible duplicate of [XMLHttpRequest cannot load https://www.\[website\].com/](https://stackoverflow.com/questions/35553500/xmlhttprequest-cannot-load-https-www-website-com) – Quentin Apr 29 '18 at 19:15

1 Answers1

-1

There is one possible workaround to bypass the problem in local tests. Using the chrome plugin https://chrome.google.com/webstore/search/access-contol-allow-origin.