Josette
Posts: 0
Joined: Mon Jun 08, 2015 10:59 pm

Use Mailgun API in Password Recovery Script

I'm trying to use the Mailgun API in the Password Recovery script in the tutorial instead of Sendgrid. However, I am unable to send the email successfully from the script. I do not get an error message and code: 0. Below is the code I'm using to send the email. I included my api key in the post url instead of the parameters.

if (XHRResponse.status == 200 && email) {
var XHRResponse = XHR.send("POST", "https://api:key-"api-key"@api.mailgun...", {
"parameters": {
"to": email,
"toname": "",
"subject": "Password Recovery",
"text": "Your recovery code is: " + secretCode + ". Copy and this code into the field provided.",
"from": "mailgun@"domain".mailgun.org"
}
});

Thank you for your help.

Mark Wong
Posts: 0
Joined: Sat Feb 14, 2015 7:47 am

Use Mailgun API in Password Recovery Script

The way I do is add the mailgun_sending service to the page and when the user choose to recover the account, then onclick javascript will create a random string and store in the localStorage variable , and the mailgun service would send it to your user.

(You have to add a REST service for updating password with headers of master key, a mailgun_sending service to your page, and a service to create the recovery code into your database)

Josette
Posts: 0
Joined: Mon Jun 08, 2015 10:59 pm

Use Mailgun API in Password Recovery Script

Is it safe to this on the client side instead of the server?

I only need a way to add the api key info to the server script.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Use Mailgun API in Password Recovery Script

Hello,

You can use secure proxy to hide you key: https://devcenter.appery.io/documenta...

John de Quarius
Posts: 0
Joined: Fri Dec 11, 2015 7:16 pm

Use Mailgun API in Password Recovery Script

Hi,

Here is a video series I've created where I'm using Mailgun and SMS (tropo) service. It's a very long video tut and two parts. The first part covers the Server Script and the second part is consuming the server code service using javascript.

I hope this would help others.

Here is the first part
https://youtu.be/k_OgJAXEfyw

Frank7390035
Posts: 0
Joined: Thu Feb 19, 2015 1:37 am

Use Mailgun API in Password Recovery Script

Hello,

I was wondering if the Appery team could share a script or plugin for password recovery / email verification using mailgun

Thanks,
Frank

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Use Mailgun API in Password Recovery Script

Hello Frank,

Sorry, but we don't have such a script. But you can write your own.
It has to send the random number to user's email and write the same number to the row of the same user in the database.

So if the user enters the recovery code you'll check it's value the same as the value in the database - let this user change the password

Return to “Issues”