I imagine there is going to be a lot of negativity in the comments, but I applaud you for not only solving a bunch of problems, but posting your code.
However, when sharing code that others might use, there are some basic recommendations that I think would help here. They aren't entirely about correctness, though some of them are.
1) Consistent style (function naming style, indent style, are these functions or not, etc). It is confusing for your end users if some of your functions look_like_this, whereas other ones lookLikeThis. Granted, PHP itself has a bunch of problems with this, but since you can easily control this, it is a nice thing to do. Same goes for the code itself and how it is indented, how brackets are used, etc.
2) No commented out lines of code. If there is an option for a particular feature in a function, it should be a $parameter in the function. Your users shouldn't have to comment and uncomment code to enable things. Comments written in english explaining code are of course fine.
3) All options should be $parameters. For example in #13, the $dir variable which affects the output filename is just hard-coded. This is an important value and should be a $parameter for the function. In #18, the reply-to and return-path should be $parameters. When you are writing functions for yourself, it is perfectly functional to hard-code these things (though not necessarily recommended). But if you are sharing it, you need to write for the most general case, so everybody can easily use parameters for their own specifics.
4) Simplest possible code. For example in #9, this function could just be the return statement and it would do the same thing. When writing for other people, every extra line of code is extra work for people to understand. If it can be written in a simpler way (that is also easy to understand), than it should be.
5) Be aware when using APIs. Quite a few of these examples use external APIs. I'd put those in a separate section, because they have external dependencies (internet connection, access keys, etc) that put them in a different class as compared to pure PHP solutions. A person using your code might not be aware of this and it could create problems for them.