I just got PHP’s mail function to work properly in my test environment.
I have a PHP app that outputs a number of strings. It would be really nice to convert these strings to attachments (*.TXT -files) in an email, without first storing them on disk and having to read them back. Would this be possible in PHP?
Yes, this is possible. You just need to make your email message a multipart message with the following syntax:
Each part can then be described like any other message. But you should probably use a library that does this for you.
Now if you’re using PHP’s
mailfunction, the first two line would be the header and the rest would be the contents of that mail message. The boundary should be a random boundary so that the possibility of having that string with--in front of it being in the contents of one part is very unlikely.