DeX's post in mail() not working in browser but works fine from command line was marked as the answer
Never mind. I was trying to run the script on the wrong server, it appears it was working the whole time on the proper server.
DeX's post in How to point last element of an array in PHP? was marked as the answer
$lastItem = $yourArray[count($yourArray) - 1]; If your array has 10 items in it, you want to point to index 9 because it's a zero based array (first item is index 0). So you want to point to the count (quantity) of items in the array minus 1.