Reputation: 1019
I have looked into the various ways of sending an email through a form on a static site. This way here @ https://sendgrid.com/blog/send-email-static-websites-using-parse/ looked the best for me! Loved the tutorial..Good stuff from Martyn Daviesonon how to do deploy cloud code and use the javascript api from parse. Thanks for sharing Martyn :)
However I have ran into an issue with actually getting this to work properly...I really want to use this method but it just needs a little fixing.
Currently I am having this error pop up in my console. It's a 400 bad request.. When I click on the link to emailer.js:28 it takes to to this in my code. This is where the error is seems to be happening in emailer.js
error: function(object, error) {
console.log(error);
$('#response').html('Error! Email not sent!').addClass('error').fadeIn('fast');
}
Lastly I don't have an email set up for my domain name. This is because I am still building this site on gh-pages. The email that I am using while I test this function is my gmail email. Is this also a potential issue? When I actually deploy this site I will use a domain name email.
Upvotes: 0
Views: 2309
Reputation: 17357
First things first.
You really should remove your Parse.com credentials from your email.js
file since from the moment you posted access to that file, anyone can use your account for pretty much any unsavory thing they fancy. Just saying.
Next, your email.js
file appears to call a server-side/cloud function called sendEmail
via parse.com's REST API but you do not appear to define that function anywhere. At least, it's not in your email.js
file. Did you already do this? Did you apply for the proper credentials from sendgrid
to allow you access to their API?
The article you mention as your inspiration defines a sendEmail() function that calls the REST API at sendgrid
to actually deliver email messages. This function is then deployed to the cloud server using the parse.com's Parse.cloud.define()
function.
If you haven't done this, then there is no function for you to call via https://api.parse.com/1/functions/sendEmail
.
Upvotes: 3