0

我的代码:

<?php 
    date_default_timezone_set("Asia/Phnom_Penh");
    $envelop['date'] = date("F j, Y, h:i");
    $envelop['from'] = "freehost0827@gmail.com";
    $envelop['to'] = "example@gmail.com";
    $envelop['subject'] = "Testing"; 

    $p['type'] = TYPETEXT;
    $p['encoding'] = ENCBASE64;
    $p['subtype'] = "plain";
    $p['description'] = "Learning to create mime";
    $p['contents.data'] = "Some text";
    $body[1] = $p; 

    print_r(imap_mail_compose($envelop, $body));
?>

执行:

$ php mime.php 
Warning: Use of undefined constant TYPETEXT - assumed 'TYPETEXT' (this will th
row an Error in a future version of PHP) in /data/data/com.termux/files/home/g
mail_api/test/mime.php on line 8 

Warning: Use of undefined constant ENCBASE64 - assumed 'ENCBASE64' (this will
throw an Error in a future version of PHP) in /data/data/com.termux/files/home
/gmail_api/test/mime.php on line 9 

Fatal error: Uncaught Error: Call to undefined function imap_mail_compose() in
 /data/data/com.termux/files/home/gmail_api/test/mime.php:15
Stack trace:
#0 {main}
  thrown in /data/data/com.termux/files/home/gmail_api/test/mime.php on line 1
5

我正在尝试使用 PHP 编写 mime 消息,imap_mail_compose()但它抱怨未定义的函数。我怎样才能解决这个问题?

4

1 回答 1

3

默认情况下,IMAP 扩展在 PHP 安装中未激活。

要激活,请在 xampp 上编辑您的 php.ini 并添加extension=php_imap.dll

在 Linux 上编辑php.ini

;从中删除;extension=imap.so

于 2019-01-18T08:04:41.800 回答