• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

how to creat mail account with php ?

M

muratak18

Guest
i have linux server and qmail installed. i want to creat mail account with php. i searched over the net but couldnt anything. Is there a way to creat mail account without plesk panel?
 
What do you mean "create mail account with PHP"? Do you want to create the mailbox from the command line? If yes, Plesk has the command line utilities, try
/usr/local/psa/bin/mail (use with --help to get the usage info).
To get the info about how to create mail account without plesk it's better to read the qmail manual
http://www.lifewithqmail.org/lwq.html
 
i have a registeration form. when users sign up , php will creat a mail account for that username like [email protected] . i dont know php can do this but i need to execute qmail and creat new mail account. how can i do this ?

thanks...
 
/usr/local/psa/bin/mail utility can create the mail account. Insert its execution with necessary parameters in the code.
 
PHP creating Boxes

Originally posted by muratak18
i have a registeration form. when users sign up , php will creat a mail account for that username like [email protected] . i dont know php can do this but i need to execute qmail and creat new mail account. how can i do this ?

thanks...

Watch out, that this form is not accessible for spammers/ hackers. ;-)

But anyway, it could be done like this (with activating DrWeb and SpamAssassin). I've used such commands in PHP-CLI:

PHP:
exec ("/usr/local/psa/bin/mail.sh --create \"".$ACCOUNT."\" -passwd \"".$PASSWD."\" -antivirus in -manage-drweb true -manage-spamfilter true -mailbox true");

$ACCOUNT should contain the full email-adress with domain.
 
Thank you Blackbit for the php code.

i have a question :

i executed the code with putty and it worked but i tried with php nothing happened and no errors. what am i doing wrong ?

i dont know much about linux command.

thank you again
 
On some servers Apache PHP doesn't allow some commands wich can be security holes, like allowing commands on your shell.

Check your PHP-Setup in /etc/php5/apache2/php.ini for this entry: disable_functions.
Maybe exec is deactivated by being listet there.

Also it might be that your PHP can't execute that target script "/usr/local/psa/bin/mail.sh". Check the execution rights. Maybe it helps to allow the group .www the execution of it:

Execute this on your SSH-Shell:
chown .www /usr/local/psa/bin/mail.sh && chmod g+x /usr/local/psa/bin/mail.sh
But remember, this can be a security problem.

Also you can find some information about this in your Apache log.
 
Another idea:

To log what happens by executing the mail-creation with this modification:

exec ("/usr/local/psa/bin/mail.sh --create \"".$ACCOUNT."\" -passwd \"".$PASSWD."\" -manage-spamfilter true -mailbox true 2&> creation.log");

Which writes all the output of mail.sh into the file creation.log. Look at this after trying to create an account.
 
Back
Top