# imap_mail_compose() vs. imap_mail()

- Thread: https://externals.io/message/23624
- Original archive: https://news-web.php.net/php.internals/23624
- Started by Oliver Block on 2006-05-23T10:19:33+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #23624 — Oliver Block — 2006-05-23T10:19:33+00:00

URL: https://externals.io/message/23624#23624

Hello,

I'd like to report another imap problem. (I've decided not to report this as a 
bug, because I don't believe it is one. I guess it is just not elaborated):

If you create a multipart/mixed message using imap_mail_compose, you have to 
provide for a multipart Content-Type header in the following way (taken from 
the manual):

   $multipart["type"] = TYPEMULTIPART;
   $multipart["subtype"] = "mixed";
   $body[] = $multipart;
   ...
Now you can add more body parts to the body.

The result will be:

MIME-Version: 1.0
Content-Type: MULTIPART/mixed; 
BOUNDARY="-559023410-851401618-1148335575=:28970"

---559023410-851401618-1148335575=:28970
[... Rest of the message ...]

If you ommit it (it is the multipart stuff above) and instead add happily 
parts to the body, the function will neither create boundaries, nor a 
multipart/mixed message. It will only create one body part -- The first one. 
OK so far.

If you use imap_mail() to send a message you are required to supply
at least three string parameters: To, Subject, Message
And you may send additional header fields "and a little more".

When the message is send using imap_mail() and we supply the multipart/mixed 
message. (from above) we would supply it as Message argument to imap_mail(). 

No the problem:
There will be a blank line between the header fields (To, Subject, addtional 
Headers) and the value of the string holding the message. The blank line 
indicates the begin of the body. That means, our

MIME-Version: 1.0
Content-Type: MULTIPART/mixed; 
BOUNDARY="-559023410-851401618-1148335575=:28970"

will never become part of the message header but of the message body.

Best Regards,

Oliver 

P.S. Just in case: If I am misunderstanding the subject of this mailing list, 
please tell me.
