如何通过 PHP 在 Cpanel 中创建电子邮件帐户?
如何使用 cPanel 中的 xmlapi.php 库通过 PHP 创建电子邮件帐户?
注意:我需要创建超过 1000 个电子邮件帐户,并想知道这是否可行。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
已更新
我已经更新了您的问题并在此基础上提供了答案。
1. 我看到 cPanel 有很多用于管理服务器的 API。虽然我没有找到用于创建新电子邮件帐户的直接 API,但找到了一个可以帮助您创建电子邮件帐户的脚本。
请参阅此链接:
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:
您可以自动创建电子邮件 ID,但需要创建一个 http 客户端,登录到您的 cpanel 界面,然后执行所需的 http 请求 > 创建电子邮件 ID(电子邮件帐户)。
Iain Clark 已提出类似的问题 (应用 .htaccess 文件夹用户名/密码与 PHP)。
如果您用 PHP 编写这样的自动化程序,则可以从 PHP 脚本创建电子邮件 ID。
类似任务的代码可以在网络上找到(例如 PHP 脚本登录 cPanel),但是您应该仔细检查它是否正确处理您的密码以及它是否确实适用于您的 cpanel 版本/样式/主题。
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.
从讨论中我最终发现您正在尝试创建一个用户名。
自动生成用户名很糟糕。但它们必须是独一无二的。为什么不让您的用户选择自己的名称并拒绝已使用的名称。
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.