如何使用php在cpanel上创建电子邮件帐户


How to create email account on cpanel using php

我正在尝试使用类似test@mydomain.com的php在cpanel中创建电子邮件帐户。我尝试了cpanel-api、xml-api等

fopen ("http://$cpuser:$cppass@$cpdomain:2083/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");

这给了我错误"Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode"

但不再有效。有人能告诉我到底是什么问题吗?我必须在服务器或其他地方设置吗。

提前感谢:)

根据错误提示,php.ini上的disabled_functions列表中可能有allow_url_fopen(默认位置为/usr/lib/php.ini)。

或者,您可以使用cPanel提供的perl脚本从命令行创建电子邮件地址:

/scripts/addpop user@domain.com password quota#
Example:
/scripts/addpop contact@abc.com password 1024 (this will create the email address contact@abc.com with the password 'password' and with 1024M (1G) as quota

如果你确实想在php脚本中使用它,那么使用php-shell_exec()函数来执行上面的命令,你就可以开始了。

我建议不要在php.ini中长期启用allow_url_fopen,并保持原样,因为这可能会给服务器带来安全风险。