zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
599 stars 96 forks source link

issue related multiple users #228

Closed priyanka1098 closed 3 years ago

priyanka1098 commented 4 years ago

Hii all, I am new to zone-mta . I have installed zone-mta in ubuntu 16.04 and also configured a user for sending mail which was perfectly working. but it works only in case of single user and not in multiple users . could you please tell me how can i configure it for multiple users.

Thanks for Help!!

louis-lau commented 4 years ago

~Not sure what you mean. If you add a second user you have multiple users right?~

priyanka1098 commented 4 years ago

@louis-lau Thanks for the reply

My concern is that i have tested sending mail to single user. it's perfectly working.

But i'm not able to add multiple users in zone-mta.

Please suggest me how can i configure multiple user & multiple credentials. Please Help!

louis-lau commented 4 years ago

Riiiight, sorry. I did not realize this was an issue on ZoneMTA. ZMTA is like a framework, if you need authentication with multiple users you need to write a plugin. Seems like a duplicate of this issue?

https://github.com/zone-eu/zone-mta/issues/225

priyanka1098 commented 4 years ago

I am very new to ZMTA so please help me to add more than one user and its credentials. i have used this plugin /zone-mta-template/plugins/example-auth.js for using user authentication . it is working only for single user. how can i configure in this file for multiple users. Thanks for help.

louis-lau commented 4 years ago

It's just JavaScript, you can do whatever you want. In the addhook function call next() if you want authentication to succeed, throw an error if you want the authentication to fail. Tha logic is up to you, this logic doesn't have to do anything with ZoneMTA. It's JavaScript :)

priyanka1098 commented 4 years ago

Sorry , I don't know JavaScript or any other programming language . so could please help me with the code for adding more users & their credentials.

andris9 commented 4 years ago

If you just want a working MTA application then you should probably look at Postfix instead. ZoneMTA is meant for setups that need more custom approach than what Postfix could provide.

ghost commented 4 years ago

I have added an API to support auth with many users

Add user to collection users

db.users.insert({"username": "user", "password": "pass"})

Add API to lib/api-server.js

this.server.get('/auth', (req, res, next) => {
            let time = new Date().toISOString();

            this.queue.mongodb
                .collection('users')
                .findOne({"username": decodeURIComponent(req.username)}, function (err, result) {
                    if (err) throw err;
                    // console.log(result);
                    if (result === null ||decodeURIComponent(req.authorization.basic.password) !== decodeURIComponent(result.password)) {
                        res.statusCode = 401;
                        res.setHeader('WWW-Authenticate', 'Basic realm="Secure Area"');
                        return res.json({
                            time,
                            error: 'Authentication required'
                        });
                    }

                    res.json({
                        user: req.username,
                        time
                    });

                });

            // the actual response does not matter as long as it's 2xx range

            next();
        });

@priyanka1098 : Hope it can help you

dazoot commented 4 years ago

Can we close this ?

dazoot commented 3 years ago

@andris9 close ?