-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Cloud Code Error Internal Server Error 1 using Mailgun #1258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Check the logs from the server when this is executed. It should be printing something out if it's hitting an internal server error. |
I see no errors on Mailgun server. |
I mean the logs from your parse-server instance. Run it locally and test. Often if the server responds with code 1, the server instance will have logged a stack trace to the console. |
But I don't know where to see the logs from cloud code. |
did you import mailgun with |
I use myMailModule-1.0.0.js |
It is not clear that this is an issue in Parse Server, as it concerns "third party" JavaScript code that is being pulled into Cloud Code. I recommend adding logs to your myMailModule-1.0.0.js file to see what Mailgun is responding with. PS: I am aware that myMailModule.js is one of Parse's own JavaScript examples, but it was written with hosted Parse applications in mind. |
Fwiw, you need to use a third party Mailgun module such as https://github.com/bojand/mailgun-js (NOT anything Parse specific - Then it is easy as this inside your cloud code function: var mailgun = require('mailgun-js')({apiKey: process.env.MAILGUN_KEY, domain: 'mg.yourapp.com'});
var mail = {
from: '[email protected]',
to: toEmail,
subject: subject,
body: '',
html: htmlBody
};
mailgun.messages().send(mail, function (sendError, body) {
if (error) {
inspect(sendError, 'mailgun sendError');
} else {
inspect(body, 'Successfully send RECEIPT email to "' + toEmail + '"');
}
}); |
I use Parse Server on the Google Cloud.
Migration works well.
I am able to read information from my classes, upload files.
It works.
I use this module:
https://github.com/ParsePlatform/JavaScriptModulesTutorial
Parse.Cloud.define("sendMail", function(request, response) {
var Mailgun = require('/my path/mailgun.js');
Mailgun.initialize('my-domaun,'api-key');
var stext=request.params.text.replace(/\n/g,'\n');
console.log('text: '+stext);
Mailgun.sendEmail({
to: "[email protected]",
from: request.params.fromEmail,
subject: request.params.subject,
text: stext
},{
success: function(httpResponse) {
console.log(httpResponse);
response.success("Email sent!");
},
error: function(httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
}
});
});
There is no saved cloud code log.
I cannot find the step by step instructions how to store log to file.
I think it is important to have a simple switch to activate the log.
Thanks.
The text was updated successfully, but these errors were encountered: