1

Topic: How to put the create user mail in a register script in php

iRedMail version: 0.9.4
OS: Debian 4.8.4-1, Linux version 3.16.0-4-amd64 (2016-04-08)
Mail accounts storage: MySQL
Web Server: Nginx
No iRedMail Pro

I've got to say, this is the best mail system I have used and it's really easy to configure. However I have a dilemma, how can I create new mail users using PHP, I've got a register script on my website and want to combine it with the create_mail_user_SQL.sh

I'm not really adept in *.sh but I'm good with PHP.

The goal for this is when a new user registers on the website it will also create an email user with the same username (after email verification), then they can change their password when they login using their own username.

Is this doable?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: How to put the create user mail in a register script in php

Just check the SQL records it inserts in create_mail_user_SQL.sh, then do the same thing in PHP. smile

3

Re: How to put the create user mail in a register script in php

How can get the values of the ones in *.sh? Like the python random script and DIR's?

4 (edited by mathieu 2016-05-07 09:24:45)

Re: How to put the create user mail in a register script in php

*EDIT-- if you are talking php and you've got root, there ain't much you can't do. Start by being real, true to yourself and others and get learning. No matter your age, sex, race, coding is great but there's absolutely no room for pretenders. Help will come 100000 times faster and of better quality if you lay the facts down and detailed. Words like dilema gets you *busted* on the scale of "i want to help you" to "figure it out yourself, master!".
-----------------------
original:

What do you want? i understand you want to add a user with your script when someone registers.
I also understand you are good at php from this "I'm not really adept in *.sh but I'm good with PHP."

If you qualify yourself as 'good' with php:
- you have some programmation knowledge, ie "code logic"
- you undoubtedly know mysql

Considering you have both things i just wrote, what's the question again?

Seriously. Even if bash scripting is not your sauce, a coder understands code logic. a coder gets simple string stuff.. or shouldn't he?? damn trivial question.

this is php, at it's most basic and soon deprecated if not already...oh.. yeah i guess you know classes and objects with php--good as you are. I didn't take a chance i wrote the simplest code ever.

<?php
    $dbhost = "localhost";
    $dbusername = "root";
    $dbpassword = "";
    $database = "vmail";
    mysql_connect($dbhost,$dbusername,$dbpassword);
    mysql_select_db($database) or die ( "Unable to select database");

    #this will list your domains
    $sql = mysql_query("SELECT * FROM domain ORDER BY domain ASC");
    while($row = mysql_fetch_array($sql)){
        $domain = $row['domain'];
        echo "$domain" . PHP_EOL;
    }

    #this will delete a domain
    $sql = "DELETE FROM domain WHERE domain = '$domain'";
    mysql_query($sql);

    # just a way of doing it, you phpmaster -- laugh at errors, that's off the top of my hat.
    $username = mysql_real_escape_string($_POSTwhatever...);
    $domain = mysql_real_escape_string(some $_POST value you got back, you know, coder.);
    $admin = 0;
    $global_admin = 0;
    $password = 'whatever';
    $hash = shell_exec("doveadm pw -s 'ssha512' -p '$password'"); #now use google if you are lost, coder.
    $sql = mysql_query("INSERT INTO mailbox SET username = '$username@$domain', password = '$hash', name = '$username', domain = '$domain', isadmin = $admin, isglobaladmin = $global_admin, maildir = '$domain/$username', created = '$time_now', local_part = '$username'");    

How many mail servers have you tried before finding this awesome piece of software you said?

Dillema doesn't even apply to your question. Ignorance and pretention do, tho.
Sorry. You are getting what you deserve while paying for others at the same time.

5

Re: How to put the create user mail in a register script in php

Gee, thank you for the "insight", I thought this is a support forum for the service that it provides. Not a $h!t fest.

6

Re: How to put the create user mail in a register script in php

Dear Shukaze,

The shell script is very simple, you just need to open it and try to understand the logic, then do the same thing in PHP. That's quite normal if you want to understand how things work with other's code.

Besides, @mathieu gave same sample php code, it's almost what you need (just replace the SQL commands).

Let's all be nice/gentle please, this is a forum for discussing technical questions/issues and helping each other, not a forum for pissing off each other.

7

Re: How to put the create user mail in a register script in php

ZhangHuangbin wrote:

Dear Shukaze,

The shell script is very simple, you just need to open it and try to understand the logic, then do the same thing in PHP. That's quite normal if you want to understand how things work with other's code.

Besides, @mathieu gave same sample php code, it's almost what you need (just replace the SQL commands).

Let's all be nice/gentle please, this is a forum for discussing technical questions/issues and helping each other, not a forum for pissing off each other.

Overboard i went, i admit. I'm taking this time to thank you, ZH, for your patience. My post edit was meant to explain the fact that i realized i overflowed, but just not enough that i remove the whole post. Thanks to everyone helping out others in a more constructive way than i did -- i guess code was almost there, i'm an old-fart -- Cheers.