Create new email account using php

spiritBreaker

Registered
Nov 1, 2019
3
1
3
Macedonia
cPanel Access Level
Website Owner
Hello all,

i am very new in the cpanel world, i have a website that uses cpanel, and i have a laravel website created. in this project, i have set up users login/creation, so now, what i want to do is, instead of going in the cpanel dashboard and create manually email address, is it possible to create new email from php?
here is my workflow i want to achieve:
user signs up on laravel frontend
the data is received in the backend, with data validation etc; lets call the user testuser
when all is fine with his data, then, i want to create an email, from laravel (my domain is lets say example.com) like: [email protected] with some password without doing it manually in the cpanel (those emails are for sending and receiving texts only, so no big quota needs to be set for them).
i've seen several scripts (ranging from the old xmlapi that is not supported anymore) to some others that use sockets, but it seems i cant get them to work.
can anyone share his knowledge on this?
 

Spirogg

Well-Known Member
Feb 21, 2018
700
161
43
chicago
cPanel Access Level
Root Administrator
maybe this will help you

 
  • Like
Reactions: spiritBreaker

spiritBreaker

Registered
Nov 1, 2019
3
1
3
Macedonia
cPanel Access Level
Website Owner
maybe this will help you

ah, ran into this article. tried the xmlapi.php, it was not working. on second try, saw that i need to get response as json to get it to work nice. the email is created as i need to now. thank you again :)
 
  • Like
Reactions: Spirogg

marih

Registered
Mar 17, 2005
2
0
151
ah, ran into this article. tried the xmlapi.php, it was not working. on second try, saw that i need to get response as json to get it to work nice. the email is created as i need to now. thank you again :)
Please share the solution or the steps you used
 

spiritBreaker

Registered
Nov 1, 2019
3
1
3
Macedonia
cPanel Access Level
Website Owner
Please share the solution or the steps you used
PHP:
$xmlapi = new xmlapi($ip);
$xmlapi->set_port($port);
$xmlapi->password_auth($account, $passwd);
[B]$xmlapi->set_output('json');[/B]
where $ip, $port, $account and $password are simple string variables containing your settings.

$xmlapi->set_output('json');

is what i added