Since Cloud Code doesn't support modules anymore, how can I still use an email service like Sendgrid to send transactional email? Right now I am using its cloud code module, but that does not work in Parse Server. Thanks for the help.
Dylan,
Were you ever able to solve your sendgrid (cloud module not supported) problem? I'm currently managing my cloud code transition and am also feeling a little lost.
Yes, I was.
package.json file, add the dependency to the Sendgrid npm module:"sendgrid": "^1.9.2"Note that instead of initializing Sendgrid with your username and password, I recommend you make an API key from the dashboard and use that instead.
Should work from there, lmk how it goes.
Thank you @dcdspace. I've since been able to require sendgrid in my projects although that didn't seem to help for sending password reset messages. I see you ran into a similar problem in issue #275. I've setup the parse-server-sendgrid-adapter (#971) to basic success - that is, I can send reset messages but the reset link doesn't work and I get "undefined" fields as shown below:
Have you been able to successfully send password resets?
EDIT **
Looks like my app name and something else (for the reset link's root) aren't specified. Any tips for how to do that?
No @zeluspudding I've only been using Sendgrid with custom templates for transactional email such as for welcome messages and in addition to push notifications for friend requests. I would however love to use my custom templates for a password reset/email verification email, so it would be great if we could directly access the reset link, and be allowed to customize the reset page.
I'm also not using the parse-server-sendgrid-adapter, but I assume it works the same as the sendgrid npm module I'm using? Also where did you find the documentation on how to use the password reset? Thanks.
@dcdspace, It appears "adapter" is synonymous with "wrapper" as parse-server-sendgrid-adapter's only dependency is sendgrid. @carmenlau wrote it and likely has more info for the both of us for getting setup correctly (I just included it in my express server initialization as shown here and got the gnarled output attached above). Any advice to get us setup with working reset password links @carmenlau? Shall we continue this conversation at #971?
After a little more poking around I've come across this - gaze your eyes upon the following:

So the fields pointed out by the number 1 in Pane A are indeed set by the appName argument when initializing ParseServer in the index.js. If you take a look at that source you can see that appName is the third argument to the ParseServer function declaration. Down at the bottom of the argument list are emailAdapter, publicServerURL , and customPages. In order to get password reset emails sent via SendGrid you'll have to set emailAdapter: SendGridAdapter as shown here. Now the portion of the reset URL denoted by the number 2 comes from setting publicServerURL. Following the reset URL takes me to Pane B, then entering my information takes me to Pane C without any sort of confirmation email. Unfortunately, when I try to use my reset password in my client, the client refuses to accept the _changed_ password - I imagine it's not really being set. So here are my questions @carmenlau (or anyone): 1) Do you have any idea why password reset isn't actually resetting passwords? 2) Do you know how I can get rid of the supposed image in the reset email (identified by the orange rectangle)? or better yet 3) can you share how one is supposed to configure custom email templates using the customPages, invalidLink, verifyEmailSuccess, choosePassword, and passwordResetSuccess arguments? Any help would be most appreciated.
Hey guys
I have followed the digital oceans guideline to migrate my application from this link :
https://www.digitalocean.com/community/tutorials/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04
now my application uses sendgrid to send very basic text emails. I have tested my cloud code without sendgrid and it works fine.
For my cloud code file it looks something like this :

now whenever I try to run this sendMail function through postman I get an internal server error :

If I click the send button multiple times I sometimes get a 502 Bad Gateway error :

Now I figured that its the sendgrid that is throwing this error so I tried to install sendgrid on my droplet.
I logged in as parse user
sudo su parse
and created a package.json and added the following to it
{
"dependencies": {
"sendgrid": "2.0.0"
}
}
i still get the same error message. I tried to install sendgripd globally as root on the droplet as well but it did not help my cloud code run
npm install -g sendgrid
I have looked around the internet and haven't found anything as close as this thread to my problem so if any of you guys know how I can fix this I will be greateful as this is the only step left for my application migration.
Cheers,
Tanzeel
Can you enable verbose logging in your server, trigger the error, and post a new issue with the output?
I'm sorry but Im not sure where I can find the log file.
I have a file ecosystem.json which has parse-wrapper information. Is that the file where I should add VERBOSE = 1 ?
I did a parse-server command in my droplet command-line saw this in the output :

So I went to my ecosystem.json file and edited it and now it loks something like this (did I set the verbose correctly ? or do I have to set it like VERBOSE=1 and what about the quotes ):

I ran the following command
pm2 restart ecosystem.json
and I guess it restarted my parse-wrapper

I can not find the log files for the parse-server on my droplet. Do you know the exact location for the log file ? I tried to look around and found nginx log files under /var/log/nginx/error.log. Since I am using nginx according to Digital Ocean's tutorial, I thought that might also help. This is what I saw in its error logs :
2016/05/11 11:34:29 [error] 18128#0: *6 connect() failed (111: Connection refused) while connecting to upstream, client: 24.37.6.210, server: test.pacecouriers.com, request: "POST /parse/functions/sendMail HTTP/1.1", upstream: "http://127.0.0.1:1337/parse/functions/sendMail", host: "test.pacecouriers.com"
Thanks 馃槃
So I looked up at pm2 and to see real-time logs the command is
pm2 logs
at first when I ran the command I saw some errors, maybe they were there from before :

Then I tried the hello cloud function from postman app to test for its output in pm2 logs and I got the following :

Next I try to run my sendMail sendgrid function and I find out the the api-key I had used in my sendgrid function was throwing an error
ReferenceError: XXXXXXXXXXXX is not defined

So I went back to my cloud code and used quotes around my api-key parameter and passed it as a string in my send grid initialize function. Then I retry and get
[Error: The provided authorization grant is invalid, expired, or revoked]

So I went back to my sendgrid account and made sure that the api-key I was using was the correct one and it seemed to be just fine. I tested again and got the same error again so I decided to generate a new api-key just in case.
So I realize that I was not using the api-key but instead API KEY ID :

When we create a new api-key on sendgrid they give us the actual api key once and they ask us to store it in some secure place :
We can only display the key above one time. Please store it somewhere safe because as soon as you navigate away from this page, we will not be able to retrieve or restore this generated token.

So after I used an actual api-key I was able to send emails 馃槂
But one small issue still remains and I am not sure if its because of postman that I am using to run cloud code or something in the parse server or nginx that is still returning me with a 502 Bad Gateway as a response

But when I look at the logs for my parse server I do see a
parse-wrapper-0 { message: 'success' }

but it never gets back to me in my postman and instead i am getting a 502 error not sure why
Thanks for helping me debug
This is expected. Also, now that you've posted your API keys, you should rotate them, or anyone can look at this page and send emails as your account.
Oh, my bad. Totally missed it. thanks :)
Most helpful comment
So I looked up at pm2 and to see real-time logs the command is
pm2 logsat first when I ran the command I saw some errors, maybe they were there from before :
Then I tried the hello cloud function from postman app to test for its output in pm2 logs and I got the following :
Next I try to run my sendMail sendgrid function and I find out the the api-key I had used in my sendgrid function was throwing an error
ReferenceError: XXXXXXXXXXXX is not definedSo I went back to my cloud code and used quotes around my api-key parameter and passed it as a string in my send grid initialize function. Then I retry and get
[Error: The provided authorization grant is invalid, expired, or revoked]So I went back to my sendgrid account and made sure that the api-key I was using was the correct one and it seemed to be just fine. I tested again and got the same error again so I decided to generate a new api-key just in case.
So I realize that I was not using the api-key but instead API KEY ID :
When we create a new api-key on sendgrid they give us the actual api key once and they ask us to store it in some secure place :
We can only display the key above one time. Please store it somewhere safe because as soon as you navigate away from this page, we will not be able to retrieve or restore this generated token.So after I used an actual api-key I was able to send emails 馃槂
But one small issue still remains and I am not sure if its because of postman that I am using to run cloud code or something in the parse server or nginx that is still returning me with a 502 Bad Gateway as a response
But when I look at the logs for my parse server I do see a
parse-wrapper-0 { message: 'success' }but it never gets back to me in my postman and instead i am getting a 502 error not sure why
Thanks for helping me debug