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?