Use API to get mail address for given username

Hello,

I want to hack a script that routes incoming mails @association.org from the server to the private mail accounts of the association members. I assume that all members have a forum account and want to reuse the already approved mail address from the forum db.

I checked the data that is returned from the forum API for a given username, but I cannot find the mail address. How do I get it?

Have you tried to PUT /users/<username>/emails.json?

1 Like

I tried and I just get a html page saying content would not exist or is private. I used the api key generated for all users and the api_user system or the username of my admin account.

I edited my previous post. This route uses the PUT verb but shouldn’t :frowning: Will fix.

I was studying the file https://github.com/discourse/discourse/blob/master/config/routes.rb but did not realised that it was PUT. Now it works. :slight_smile:

2 Likes

There you go :ear_of_rice:

https://github.com/discourse/discourse/commit/c4b52b1a19e7cacdcd84989bd9309b6d35df9e55

3 Likes

The point of that being non-GET is that it causes a staff action log, so it shouldn’t be triggereable from an img or an idempotent request retry thing.

2 Likes