15

How do I create email accounts with PHP using the xmlapi.php library from cPanel?

Note: I need to create more than 1000 email accounts and want to know if this is possible.

Thanks.

Andre F
  • 423
  • 4
  • 11
Mohandass
  • 157
  • 1
  • 1
  • 6
  • You mean Message-IDs (the ones you use in e-mail headers)? – Alix Axel Jun 21 '11 at 08:12
  • 13
    How is this up-voted already? I can't even begin to understand this question... – Alix Axel Jun 21 '11 at 08:12
  • Can you give an example of what you mean by an "email id"? – Matt Gibson Jun 21 '11 at 08:25
  • @Matt Gibson: He means an email account. *... need to have a mail id from my domain (for eg : parrot@mysite.com )* – hakre Jun 21 '11 at 08:33
  • I need to create an email id as " alex@mysite.com " for the person alex while he registers in my website. – Mohandass Jun 21 '11 at 08:33
  • That's usually refered to as an email address (although more correctly its an ADDR-SPEC) – symcbean Jun 21 '11 at 11:59
  • Should not have been closed. This question is asking how to use the cPanel API to create an email account. Heres the link to the API function: http://docs.cpanel.net/twiki/bin/vief/ApiDocs/Api2/ApiEmail#Account%20functions – Citizen Kepler Nov 03 '13 at 15:43
  • 2
    Yet *another* example on Stack of, "I don't understand the question so we must blindly vote-to-close." BS. >__> – John Jun 13 '18 at 21:59

3 Answers3

6

UPDATED

I have updated your question and based on that providing this answer.

1. I see bunch of API's for cPanel for managing the server. Though I don't find a direct API for creating a new email account, but found a script which would help you creating email account.

Please see this link:

http://www.zubrag.com/scripts/cpanel-create-email-account.php

http://forums.cpanel.net/f42/xmlapi-php-class-111897.html

Community
  • 1
  • 1
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66
  • correct, i do not think any host will allow you to do that. – Ibrahim Azhar Armar Jun 21 '11 at 08:19
  • I have a control panel access and able to create email ids form cpanel. But i need a option to create members who register in my site will need to have a mail id from my domain (for eg : parrot@mysite.com ) so is this possible to do ? Thanks... – Mohandass Jun 21 '11 at 08:20
  • 1
    @Mohandass: See http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/WebHome – Alix Axel Jun 21 '11 at 08:22
0

You can automate the creation of email id's but creating a http-client that is logging into you cpanel-interface and then performing the needed http-requests to create the email-ids (email accounts).

Something similar has been asked by Iain Clark (Applying .htaccess folder username/password with PHP).

If you write such an automation in PHP you can then create Email-IDs from your PHP script.

Code for similar tasks can be found here and there in the web (e.g. PHP Script To Log Into cPanel), however you should carefully check if that is dealing with your passwords appropriate and that it actually works for your version/style/theme of cpanel.

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
0

From the discussion I eventually worked out that you're trying to create a username.

Automatic generation of usernames sucks. They do have to be unique though. Why not let your users pick their own names and reject ones that are already in use.

symcbean
  • 47,736
  • 6
  • 59
  • 94