通过PHP访问Webmail

3
我有Cpanel和域名。我可以通过进入Cpanel中的电子邮件帐户选项来创建电子邮件帐户。我的问题是如何从php Web应用程序在Cpanel中创建电子邮件帐户?我想要一个正确的指南。
提前感谢。

请尝试访问http://forums.cpanel.net/f43/create-e-mail-accounts-e-mail-forwarding-without-logging-c-panel-dynamic-way-217551.html。 - Flaxbeard
那不够充分。你能给我推荐其他资源吗? - user1731476
尝试一下这个,它是从那个页面链接过来的,看起来应该可以工作:http://forums.cpanel.net/f42/php-script-generating-forwarders-programmatically-115569.html 第二篇帖子介绍了使用XML创建转发器的方法。 - Flaxbeard
我认为这是不可能的,除非你可以访问服务器(VPS)。如果我错了,请纠正我。 - twodayslate
2个回答

0

看这个。它是针对Gmail账户的。为您的账户进行配置:

/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'username@gmail.com';
$password = 'password here';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' .   imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');

/* if emails are returned, cycle through each... */
   if($emails) {

/* begin output var */
$output = '';

/* put the newest emails on top */
rsort($emails);

/* for every email... */
foreach($emails as $email_number) {

    /* get information specific to this email */
    $overview = imap_fetch_overview($inbox,$email_number,0);
    $message = imap_fetchbody($inbox,$email_number,2);

    /* output the email header information */
    $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
    $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
    $output.= '<span class="from">'.$overview[0]->from.'</span>';
    $output.= '<span class="date">on '.$overview[0]->date.'</span>';
    $output.= '</div>';

    /* output the email body */
    $output.= '<div class="body">'.$message.'</div>';
}

echo $output;
} 

/* close the connection */
imap_close($inbox);

我认为这会对你有所帮助。谢谢。razin223


问题是如何使用PHP创建电子邮件帐户,而不是查看电子邮件帐户的邮件。不过这个脚本非常酷 :) - twodayslate

0

很棒的解决方案!不过你怎么让它更安全呢? - twodayslate

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接