0

My code:

<?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));
?>

Executing:

$ 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

I am trying to compose a mime message using PHP with imap_mail_compose() but it complained about an undefined function. How can I fix this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
usr11011
  • 1
  • 4

1 Answers1

3

By Default, IMAP extension is not activated in PHP installation.

For activation edit your php.ini on xampp and add extension=php_imap.dll

On Linux edit php.ini

Remove ; from ;extension=imap.so