如何使用 PHP/SQL 为我的用户提供电子邮件地址并设置 Webmail


How to give my users email addresses with PHP/SQL and set up Webmail?

我到处找过,大多数回复都是关于使用电子邮件地址验证用户帐户的。我已经有了。我有一个完整的登录/注册/帐户系统以及新闻提要和朋友系统,消息等。

但是,我想要的是一种让用户能够注册电子邮件帐户的方法。

假设他们去 example.com 注册一个帐户,一旦他们注册,他们就会收到一封 username@example.com 的电子邮件,他们可以查看他们的收件箱/发件箱文件夹,并将邮件发送到任何地方,而不仅仅是在网站上向其他人发送消息。我有几个域名想这样做。

我没有专用服务器或root访问权限,但我有cPanel和访问权限,可以执行与我的Web服务相关的几乎所有操作。无限的电子邮件/能够使用外部客户端、域、子域、带宽、存储等。所以我认为对我必须设置的特定内容没有任何限制。

如何使用 PHP 注册电子邮件,以及访问收件箱/发件箱?

我想

自己创建它,以便我可以用我自己的网站实现它,所以我想避免使用 RoundCube 或其他类似的网络邮件服务。

以编程方式创建电子邮件帐户是100%可能的,请从我的工作实时项目之一中找到下面的代码

include("xmlapi.php");   //XMLAPI cpanel client class
// Default whm/cpanel account info
$ip = ""; // should be server IP address or 127.0.0.1 if local server
$account = "";// cpanel user account name
$passwd = '';// cpanel user password
$port =2083;// cpanel secure authentication port unsecure port# 2082
$email_domain = "";// email domain (usually same as cPanel domain)
$email_quota = 50; // default amount of space in megabytes
/*************End of Setting***********************/
$xmlapi = new xmlapi($ip);
$xmlapi->set_port($port);  //set port number. cpanel client class allow you to access WHM as well using WHM port.
$xmlapi->password_auth($account, $passwd);   // authorization with password. not as secure as hash.
// cpanel email addpop function Parameters
$call = array(domain=>$email_domain, email=>$email_user, password=>$email_pass, quota=>$email_quota);
//$xmlapi->set_debug(1);//output to error file  set to 1 to see error_log.
// making call to cpanel api
$result = $xmlapi->api2_query($account, "Email", "addpop", $call );
// cpanel email fwdopt function Parameters
$dest_email="";// if  specified by user in the form 
$call_f  = array(domain=>$email_domain, email=>$email_user, fwdopt=>"fwd", fwdemail=>$dest_email);
$result_forward = $xmlapi->api2_query($account, "Email", "addforward", $call_f); //create a forward if you want

if ($result->data->result == 1){
    $msg = $email_user.'@'.$email_domain.' account created';

这是类文件 xmlapi.php

$email_quota = 50;//默认空间量(以兆字节为单位)

相关文章: