Hello,

Is there a way to create new email accounts using php? There must be right? Many sites will give you a mailbox as soon as you register.
How do they do it?

Hello,

Is there a way to create new email accounts using php? There must be right? Many sites will give you a mailbox as soon as you register.
How do they do it?

This is for Linux, I don't have any experience with Windows Mail Servers.

Mail servers (MTAs) by default will generally save user mail under their user accounts (shell accounts).

Thus email accounts, are tied to user accounts on the server. So in order to provide mail for a user you have to create an account for them on the server.

Creating user accounts can only be done as root.

PHP running on the server, unfortunately cannot create user accounts directly since the PHP script executes under the webserver user, which won't be root due to security concerns.
You could switch to root from PHP, or invoke a shell script that runs with root privileges, but this has security concerns.

Most the MTA's (http://en.wikipedia.org/wiki/List_of_mail_servers) will allow you to create virtual mail boxes however, that are not tied to user accounts.

Depending on the MTA you use, the way of creating the virtual mail boxes is different, and the setup of the MTA to allow this is different also.

Creating the virtual mail boxes usually means adding to a file that lists the usernames and password hashes, or you can have the users saved in a database.

All you'll need is for PHP to update the virtual users file, or update the database table that holds the virtual users and you will be able to manage new users.

Which mail server (MTA) are you using for your site?

hey digital ether ,
u provide really a good post ie answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.